Echelon Neuron C Manuel d'utilisateur

Naviguer en ligne ou télécharger Manuel d'utilisateur pour Logiciel Echelon Neuron C. Echelon Neuron C User Manual Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 268
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs

Résumé du contenu

Page 1 - C Programmer’s Guide

0 7 8 - 0 0 0 2 -02H®Neuron®C Programmer’s Guide

Page 2

x The resp_receive( ) Function ... 139 Format of a Response...

Page 3 - Audience

88 Using Configuration Properties to Configure Device Behavior 4 If the configuration property type for the configur

Page 4 - Related Documentation

Neuron C Programmer’s Guide 89 identify the association between the configuration property and the object or objects to which it applies. Dev

Page 5

90 Using Configuration Properties to Configure Device Behavior A Neuron C program can have multiple device property l

Page 6

Neuron C Programmer’s Guide 91 member that is shared between two or more network variables. The use of the static keyword creates a CP famil

Page 7 - Table of Contents

92 Using Configuration Properties to Configure Device Behavior Since the same CP family could also be used as a devic

Page 8

Neuron C Programmer’s Guide 93 network output SNVT_volt nvoVoltage[4]; Now, suppose that we want to provide a SCPTmaxSendTime configuration p

Page 9

94 Using Configuration Properties to Configure Device Behavior scenario, where part of the configuration property net

Page 10

Neuron C Programmer’s Guide 95 Initialization of Configuration Properties at Instantiation You can initialize a configuration property of fix

Page 11

96 Using Configuration Properties to Configure Device Behavior network output SNVT_amp nvoB nv_properties { nciPwrU

Page 12

Neuron C Programmer’s Guide 97 static cpMaxSendT // Shared among the array // elements only }; Although the discussion above concer

Page 13

Neuron C Programmer’s Guide xi Chips without Off-Chip Memory ... 177 Memory Regions ...

Page 14 - What Is Neuron C?

98 Using Configuration Properties to Configure Device Behavior requirements of all individually listed FPT members (f

Page 15 - Unique Aspects of Neuron C

Neuron C Programmer’s Guide 99 functional profile is an example of a functional profile that lists the SCPTdefOutput configuration property a

Page 16 - Neuron C Integer Constants

100 Using Configuration Properties to Configure Device Behavior responsibility of the network tool to apply the forma

Page 17 - Neuron C Variable Types

Neuron C Programmer’s Guide 101 5 Using Functional Blocks to Implement a Device Interface This chapter discusses the use of functional blo

Page 18 - Neuron C Storage Classes

102 Using Functional Blocks to Implement a Device Interface Overview The device interface for a LONWORKS device cons

Page 19 - Neuron C Declarations

Neuron C Programmer’s Guide 103 defined by the functional profile – these are called implementation-specific network variables and configurat

Page 20

104 Using Functional Blocks to Implement a Device Interface and some required data structures that implement a functi

Page 21 - Configuration Properties

Neuron C Programmer’s Guide 105 Example: network output SNVT_amp nvoAmpere; fblock SFPTopenLoopSensor { nvoAmpere implements nvoValue; } f

Page 22

106 Using Functional Blocks to Implement a Device Interface added per line. In this way, a functional block can cont

Page 23 - I/O Devices

Neuron C Programmer’s Guide 107 to provide language-dependent names for your functional blocks. The external name is discussed in more detai

Page 24

xii Appendix A. Neuron C Tools Stand-Alone Use...211 Stand-Alone Tools ...

Page 25 - Functions

108 Using Functional Blocks to Implement a Device Interface Shared Functional Block Properties Just as network variab

Page 26

Neuron C Programmer’s Guide 109 fb_properties { cpGain, static cpUpdateRate, global cpBypassTime }; fblock SFPTopenLoopSensor { nv

Page 27 - Focusing on a Single Device

110 Using Functional Blocks to Implement a Device Interface 1 Use the NodeBuilder Resource Editor to create a user f

Page 28 - When Clauses

Neuron C Programmer’s Guide 111 This expression uses the network variable’s member identifier, not the network variable’s unique name. Using

Page 29 - When Statement

112 Using Functional Blocks to Implement a Device Interface // reference of CP family, not CP family member cpGain.m

Page 30 - Predefined Events

Neuron C Programmer’s Guide 113 between the internal and external names of configuration properties, you should preserve some degree of simil

Page 31

114 Using Functional Blocks to Implement a Device Interface Node Object implementation can then direct this request t

Page 32 - Event Processing

Neuron C Programmer’s Guide 115 fblock_director(nviRequest.object_id, nviRequest.object_request); } } Likewise, a single task can ha

Page 33 - Reset Event

116 Using Functional Blocks to Implement a Device Interface

Page 34 - Scheduling of When Clauses

Neuron C Programmer’s Guide 117 6 How Devices Communicate Using Application Messages This chapter describes the use of application message

Page 35 - Priority When Clauses

Neuron C Programmer’s Guide 1 1 Overview This chapter introduces the Neuron C Version 2.2 programming language. It describes the basic asp

Page 36 - Function Prototypes

118 How Devices Communicate Using Application Messages Introduction to Application Messages Application messages are

Page 37 - Declaring Timers

Neuron C Programmer’s Guide 119 Layers of Neuron Software When you use network variables in a program, the actual building and sending of mes

Page 38 - The timer_expires Event

120 How Devices Communicate Using Application Messages Application Messages You can explicitly create a message using

Page 39 - Input/Output

Neuron C Programmer’s Guide 121 and one incoming message (or response) at any one time. For example, you cannot build up two messages in par

Page 40 - I/O Object Types

122 How Devices Communicate Using Application Messages the message does not need to be authenticated. The default is

Page 41

Neuron C Programmer’s Guide 123 It might not always be possible to determine rate_est and max_rate_est. For example, message output rates ar

Page 42 - Device Self-Documentation

124 How Devices Communicate Using Application Messages Type of Message Message Code Description Responder Offline

Page 43

Neuron C Programmer’s Guide 125 Example block transfer of data: msg_tag motor; #define MOTOR_ON 0 typedef enum { MOTOR_FWD, MOTOR_REV

Page 44

126 How Devices Communicate Using Application Messages void msg_cancel(void); This function cancels the message being

Page 45

Neuron C Programmer’s Guide 127 { // Do nothing, just discard it } To prevent the incoming message queue from becoming blocked, a program

Page 46 - Dimmer Switch

2 Overview What Is Neuron C? Neuron C Version 2 is a programming language based on ANSI C that is designed for Neuron Chips and Smart Transceivers.

Page 47

128 How Devices Communicate Using Application Messages Important: Assigning values to the msg_out object can invalid

Page 48 - Fixed Timers

Neuron C Programmer’s Guide 129 If a message were to arrive and the application fail to process it, that message would remain at the head of

Page 49 - With a 10 MHz Input Clock

130 How Devices Communicate Using Application Messages #define OFF 0 #define ON 1 // I/O Declaration IO_4 input bit

Page 50 - With Other Clock Speeds

Neuron C Programmer’s Guide 131 See Message Tags on page 122 for a more detailed discussion of the nonbind option. The use of explicit addres

Page 51 - Repeating Timers

132 How Devices Communicate Using Application Messages the event. See the Predefined Events chapter in the Neuron C

Page 52 - Delay Functions

Neuron C Programmer’s Guide 133 Processing Completion Events for Messages When you send a message, you can optionally check the completion ev

Page 53 - EEPROM Write Timer

134 How Devices Communicate Using Application Messages msg_send(); } when (msg_fails(TAG1)) { failures[0]++; }

Page 54

Neuron C Programmer’s Guide 135 { // build a message // send the message } when (msg_completes) { msg_out.tag = t; // This seque

Page 55 - Network Variables

136 How Devices Communicate Using Application Messages The following example indicates one way asynchronous and direc

Page 56 - Major Topics

Neuron C Programmer’s Guide 137 Important: Because an Interoperable Self-Installation (ISI) network uses unbounded groups (group size 0), yo

Page 57

Neuron C Programmer’s Guide 3 • fb_properties • nv_properties • device_properties • cp • cp_family You can still manually create the s

Page 58

138 How Devices Communicate Using Application Messages Because the response is returned to the origin of the request,

Page 59 - Declaring Network Variables

Neuron C Programmer’s Guide 139 Its syntax is the following: resp_arrives [(msg-tag-name)] If a response arrives, this event evaluates to TRU

Page 60

140 How Devices Communicate Using Application Messages To use this field, you must include the <addrdefs.h> a

Page 61 - Connecting Network Variables

Neuron C Programmer’s Guide 141 msg_send(); // send the message // wait for completion while (!msg_succeeds(motor)) { post_ev

Page 62

142 How Devices Communicate Using Application Messages sends any repeated requests to the application and the applica

Page 63 - The nv_update_occurs Event

Neuron C Programmer’s Guide 143 • Two application input buffers See Chapter 8, Memory Management, on page 173, for a discussion of buffer

Page 64 - Neuron C Reference

144 How Devices Communicate Using Application Messages task. However, you might want to free an application input bu

Page 65 - Preemption Mode

Neuron C Programmer’s Guide 145 7 Additional Features This chapter describes additional features in Neuron C. It describes the scheduler

Page 66

146 Additional Features The Scheduler Chapter 2, Focusing on a Single Device, on page 15, introduced the basic functio

Page 67 - Variables

Neuron C Programmer’s Guide 147 RestartOrPower-UpInitializationReset TaskTop of Scheduling LoopTaskTwhen (offline)TaskTwhen (online)TaskTwhen

Page 68 - Polling Network Variables

4 Overview Neuron C is designed to execute in the environment provided by the Neuron system firmware. This firmware provides an event-driven schedu

Page 69

148 Additional Features Outgoing messages, network variable updates, and network variable polls use application output

Page 70

Neuron C Programmer’s Guide 149 become TRUE. It is thus important that these when clauses be evaluated in their given order after a network

Page 71

150 Additional Features Watchdog Timer For Series 3100 devices, the watchdog timer times out within a range of 0.21 se

Page 72

Neuron C Programmer’s Guide 151 Additional Predefined Events The following three predefined special events result from network management mes

Page 73

152 Additional Features // handle case of device going online if (online) { HandleOnline(); } } when (online)

Page 74

Neuron C Programmer’s Guide 153 device, so events can be processed only through direct event processing. Neither network variable updates, n

Page 75

154 Additional Features I/O Interrupts The Series 5000 hardware supports two independent I/O interrupts, each derived

Page 76

Neuron C Programmer’s Guide 155 associated periodic system timer interrupt as needed; see Controlling Interrupts on page 159. One applicatio

Page 77 - Monitoring Network Variables

156 Additional Features Table 10. I/O Interrupt Triggers Trigger Type Example Interrupt Specification Positive level

Page 78 - Authentication

Neuron C Programmer’s Guide 157 • Infrared Input • Infrared Pattern Output • Oneshot Output • Ontime Input • Period Input • Pulsecount

Page 79 - How Authentication Works

Neuron C Programmer’s Guide 5 0x0 .. 0x7F signed short 0x80 .. 0xFF unsigned short 0x100 .. 0x7FFF signed long 0x8000 .. 0xFFFF unsig

Page 80

158 Additional Features • Infrared input • Ontime input • Period input • Pulsecount input • Stretched triac outpu

Page 81

Neuron C Programmer’s Guide 159 ... } interrupt(repeating, “3456.789Hz”) { ... } interrupt(repeating, ”625E3”) { // 625 kHz

Page 82

160 Additional Features You can call the interrupt_control() function at any time to enable or disable one or more of

Page 83

Neuron C Programmer’s Guide 161 Sharing Data with an Interrupt Task In general, an interrupt task can access any data that the main applicati

Page 84 - Validating a Type Change

162 Additional Features Example: unsigned long globalVariable; void f() { __lock { globalVariable = ...;

Page 85 - Processing a Type Change

Neuron C Programmer’s Guide 163 At the end of this preparation, the system firmware calls the interrupt dispatcher within the Neuron C applic

Page 86 - Processing a Size Change

164 Additional Features Figure 15. Interrupt Latency As the figure shows, the first (in source-code declaration order

Page 87 - Changeable-Type Example

Neuron C Programmer’s Guide 165 out, and the device resets. To avoid the watchdog timer reset, use the #pragma deadlock_is_infinite compiler

Page 88

166 Additional Features Flushing the Neuron Chip or Smart Transceiver You can use the flush( ) function to instruct th

Page 89

Neuron C Programmer’s Guide 167 COMM_IGNORE Causes incoming messages to be ignored. PULLUPS_ON Enables all internal pullup resistors for S

Page 90

6 Overview Neuron C Storage Classes If no class is specified and the declaration is at file scope, the data or function is global. File scope is th

Page 91

168 Additional Features Forced Sleep You can force a device to sleep even though a flush operation is not complete. U

Page 92

Neuron C Programmer’s Guide 169 • Log an error These actions can be combined. For example, you can log an error and then take the applicat

Page 93 - } // SetCurrent()

170 Additional Features Taking an Application Offline You can take a device offline using the go_offline( ) function.

Page 94

Neuron C Programmer’s Guide 171 See the FT 5000 EVB Examples Guide or the NodeBuilder FX/PL Examples Guide for more examples of using the fbl

Page 95 - Configure Device Behavior

172 Additional Features Access to Device Status and Statistics From your application program, you can access the same

Page 96

Neuron C Programmer’s Guide 173 8 Memory Management This chapter describes system memory resources, such as on-chip EEPROM, application bu

Page 97 - ONWORKS file transfer

174 Memory Management Memory Use This section outlines the amount of memory used by certain elements in your program.

Page 98

Neuron C Programmer’s Guide 175 • Each address table entry requires 5 bytes. A maximum of 15 address table entries are allowed. The minimu

Page 99

176 Memory Management Using Neuron Chip Memory The following section describes two different situations, using Neuron

Page 100

Neuron C Programmer’s Guide 177 Chips without Off-Chip Memory On-chip memory on the Neuron 3120 Chips and on the FT 3120 Smart Transceiver co

Page 101 - Device Property Lists

Neuron C Programmer’s Guide 7 uninit When combined with the eeprom keyword (see below), specifies that the EEPROM variable is not initialize

Page 102 - Neuron C Reference Guide

178 Memory Management Neuron firmware and can optionally (only on a Neuron 3150 Chip or FT 3150 Smart Transceiver) con

Page 103

Neuron C Programmer’s Guide 179 • The ROM region has a system area and a user area (Neuron 3150 Chip and FT 3150 Smart Transceiver only). T

Page 104 - Properties

180 Memory Management compiler and linker to place specific objects in the offchip and onchip RAMFAR areas, respective

Page 105

Neuron C Programmer’s Guide 181 Controlling Non-Default Memory Usage If you receive an error message at link time that part of your program d

Page 106

182 Memory Management eeprom variables. Restarting a device or powering it up does not re-initialize the eeprom varia

Page 107 - Instantiation

Neuron C Programmer’s Guide 183 offchip Keyword (for Functions and Data Declarations) The Neuron linker typically places code, const data, an

Page 108

184 Memory Management if the device is to be protected against a power cycle. See the Neuron 3150 Chip External Memor

Page 109

Neuron C Programmer’s Guide 185 Use of Flash Memory for Series 3100 Chips For the Neuron 3150 Chip and the FT 3150 Smart Transceiver, Neuron

Page 110

186 Memory Management Any direct write by the application to the flash memory causes a programming cycle, even if the

Page 111

Neuron C Programmer’s Guide 187 The flash memory that is used for the EECODE data is erased once during the application load process. If pre

Page 112

Echelon, LONWORKS, LONMARK, NodeBuilder, LonTalk, Neuron, 3120, 3150, ShortStack, LonMaker, and the Echelon logo are trademarks of Echelon Corporation

Page 113 - Implement a Device Interface

8 Overview Declaration Example Data types typedef unsigned long ULONG; Enumerations enum hue {RED, GREEN, BLUE}; Pointers char *p; Functions in

Page 114 - Overview

188 Memory Management provided to write by pointers which can (but are not required to) refer to EEPROM or flash memor

Page 115 - Resources

Neuron C Programmer’s Guide 189 By default, the address table contains 15 entries. Each address table entry uses five bytes of on-chip EEPRO

Page 116

190 Memory Management The maximum number of aliases for applications developed with the Mini EVK Evaluation Kit or the

Page 117

Neuron C Programmer’s Guide 191 ApplicationSchedulerNetworkMACHardwareSender Device (writer)ApplicationSchedulerNetworkMACHardwareReceiver De

Page 118 - The Director Function

192 Memory Management If explicit addressing is used, add an additional 11 bytes of system overhead. For application m

Page 119

Neuron C Programmer’s Guide 193 • If your device is installed with unicast connections (that is, one device sends a network variable or mess

Page 120

194 Memory Management buffers; the second directive specifies that the compiler should define exactly 114-byte buffers

Page 121 - Scope Rules

Neuron C Programmer’s Guide 195 Sets the number of network buffers available for outgoing priority messages and network variables. Incoming N

Page 122

196 Memory Management address, destination address, and priority attribute vector into an existing receive transaction

Page 123

Neuron C Programmer’s Guide 197 Pragma Values Allowed Default (See Notes) app_buf_in_size (20, 21, 22, 24, 26, 30), 34, 42, 50, 66, 82, 114

Page 124

Neuron C Programmer’s Guide 9 declared with the polled modifier), the new value of the network variable is propagated across the network to a

Page 125

198 Memory Management If explicit addressing is used for network variables: C = max(34, 19 + sizeof(largest NV)) The a

Page 126

Neuron C Programmer’s Guide 199 unsigned short int controlReg2; unsigned long int dataReg; } *PMemMapDev; const PMemMapDev pDevice =

Page 127 - Behavior

200 Memory Management also included in the optionally produced link map file (if your Neuron C development tool suppor

Page 128

Neuron C Programmer’s Guide 201 can consider removing the self-identification data. You can do this by specifying the following compiler dir

Page 129 - Application Messages

202 Memory Management Use Efficient Constant Values In the Neuron Chip and Smart Transceiver CPU architecture, constan

Page 130 - ONWORKS

Neuron C Programmer’s Guide 203 The Neuron C utility functions include byte-manipulation functions, such as high_byte( ), low_byte( ), make_l

Page 131 - Layers of Neuron Software

204 Memory Management In addition to the code size numbers, all sequences above, except the one for unsigned short, ma

Page 132 - Constructing a Message

Neuron C Programmer’s Guide 205 Use the Optional fastaccess Feature Array accesses (both loads and stores) in Neuron C normally use the rules

Page 133 - Management

206 Memory Management void f(void) { int temp; temp = b * c * 4; d = (a * 2) + temp; e = a - temp; } A

Page 134

Neuron C Programmer’s Guide 207 Use the Alternate Initialization Sequence Use of the #pragma disable_mult_module_init directive saves 2 or 3

Page 135

10 Overview configuration data. Like network variables, configuration properties also provide a well-defined interface. Each configuration propert

Page 136 - Block Transfers of Data

208 Memory Management } else if (c == '3') { f3(); } else if (c == '4') { f4(); } else {

Page 137 - Sending a Message

Neuron C Programmer’s Guide 209 For example, if a program has two input network variables, and has a single task executed when either variabl

Page 138 - The msg_arrives Event

210 Memory Management different set of system library functions might need to be linked into the application space (fr

Page 139 - The msg_receive( ) Function

Neuron C Programmer’s Guide 211 A Neuron C Tools Stand-Alone Use This appendix provides information on how to use the Neuron C tools as stan

Page 140

212 Neuron C Tools Stand-Alone Use Stand-Alone Tools The Neuron C tools listed in Table 15 can be used stand-alone, m

Page 141 - Switch Program

Neuron C Programmer’s Guide 213 Usage: [optional command(s)] argument ... (Remaining output not listed here) Most command switches come in t

Page 142 - Explicit Addressing

214 Neuron C Tools Stand-Alone Use --basename=23305 Most tools require additional arguments to be given; these argume

Page 143 - Message Completion Events

Neuron C Programmer’s Guide 215 Important: Specify the scriptfile script file in such a way that it does not overwrite the default script fi

Page 144

216 Neuron C Tools Stand-Alone Use C:\>ncc –Imyincs -DOPTION1 myfile.nc This command (assuming the compilation doe

Page 145 - Messages

Neuron C Programmer’s Guide 217 EEPROM, respectively. The -Z switch is used to specify the last page of ROM (there is no corresponding switc

Page 146 - Preemption Mode and Messages

Neuron C Programmer’s Guide 11 of this feature in Chapter 3, How Devices Communicate Using Network Variables, on page 43, and also in the Neu

Page 147

218 Neuron C Tools Stand-Alone Use The exporter command line contains a number of switches. Several switches must be

Page 148

Neuron C Programmer’s Guide 219 Neuron Librarian The Neuron librarian is named nlib.exe. You can use the librarian to create and manage libr

Page 149 - Constructing a Response

220 Neuron C Tools Stand-Alone Use f8.no f9.no f10.no The librarian command line can contain more than one script fil

Page 150 - The resp_arrives Event

Neuron C Programmer’s Guide 221 B Neuron C Function Libraries This appendix discusses how to construct and use your own function and data li

Page 151 - Format of a Response

222 Neuron C Function Libraries Definitions Application program A Neuron C source program that has been compiled, as

Page 152 - Request/Response Examples

Neuron C Programmer’s Guide 223 The linker only looks at libraries when the object files being linked and combined with the system image file

Page 153

224 Neuron C Function Libraries 2 The NodeBuilder project manager cannot be used to manage the dependencies of a lib

Page 154 - Application Buffers

Neuron C Programmer’s Guide 225 Use these include files in the library source files that define these functions and data objects as well, s

Page 155 - Reference Guide

226 Neuron C Function Libraries then placing the Neuron C code in the include file for the utility, the utility can e

Page 156

Neuron C Programmer’s Guide 227 C Neuron C Custom System Images This appendix discusses how to build and use your own custom system images fo

Page 157 - Additional Features

12 Overview Neuron-Hosted and Host-Based Compilation Compilation for Neuron-hosted devices, that is, devices based on a Neuron Chip or Smart Transc

Page 158 - Scheduler Reset Mechanism

228 Neuron C Custom System Images Definitions Application program A Neuron C source program that has been compiled,

Page 159 - Interrupts

Neuron C Programmer’s Guide 229 BFT5000 - Firmware incorporated into a Neuron 5000 Processor or an FT 5000 Smart Transceiver. SYS3150

Page 160 - Scheduler Example

230 Neuron C Custom System Images consists of the following: image.nx Loadable image in Intel hex format image.nxb

Page 161 - The post_events( ) Function

Neuron C Programmer’s Guide 231 3 A custom system image can only contain pure C functions and data objects. It cannot contain Neuron C exte

Page 162 - Watchdog Timer

232 Neuron C Custom System Images 1 Run the stand-alone Neuron linker as described in Appendix A. In addition to th

Page 163 - Additional Predefined Events

Neuron C Programmer’s Guide 233 file. The output files are directed (with the "-o" switch) to files named "myimage.*." n

Page 164 - Wink Event

234 Neuron C Custom System Images limit is cumulative, in other words, the two (or more) images cannot use more than

Page 165 - Interrupt Sources

Neuron C Programmer’s Guide 235 As for the I/O operations on the display, assume that the display has a Neurowire device interface. The cust

Page 167 - Defining an Interrupt Task

Neuron C Programmer’s Guide 237 D Neuron C Language Implementation Characteristics This appendix discusses how the Neuron C language impleme

Page 168

Neuron C Programmer’s Guide 13 Differences between Neuron C and ANSI C Neuron C adheres closely to the ANSI C language standard; however, Neu

Page 169

238 Neuron C Language Implementation Characteristics Neuron C Language Implementation Characteristics The Internation

Page 170

Neuron C Programmer’s Guide 239 Environment (J.3.2) Q: What are the semantics of the arguments to main? (Sec. 5.1.2.2.1) A: Neuron C plac

Page 171 - )]',255min(,0max[ Zn =

240 Neuron C Language Implementation Characteristics Characters (J.3.4) Q: What are the members of the source and ex

Page 172

Neuron C Programmer’s Guide 241 Q: What are the number of bits in a character in the execution character set? What is the size of a wide ch

Page 173

242 Neuron C Language Implementation Characteristics -128 .. 127 signed short 0 .. 255 unsigned s

Page 174 - Interrupt Latency

Neuron C Programmer’s Guide 243 Hints (J.3.8) Q: What is the extent to which objects are actually placed in registers by use of the register

Page 175

244 Neuron C Language Implementation Characteristics Qualifiers (J.3.10) Q: What constitutes an access to an object

Page 176 - Debugging Interrupt Tasks

Neuron C Programmer’s Guide 245 the directories specified in Include Directories of the NodeBuilder Device Templates Properties dialog and Pr

Page 178 - Putting the Device to Sleep

Neuron C Programmer’s Guide 247 Index # #elif, 14 #if, 14 #line, 14 / /* */ comment style, 14 // comment style, 14 @ @ (at-sign character), 2

Page 179 - Forced Sleep

14 Overview include file. Other ANSI C library functions, such as file I/O and storage allocation functions, are not included in Neuron C. Consult

Page 180 - Error Handling

248 Index size, 191 application output buffers freed by completion events, 148 components of, 191 counts, 192 effect

Page 181 - Restarting the Application

Neuron C Programmer’s Guide 249 conversion cast, 242 integer, 241 pointer, 242 cp keyword. See config_prop keyword cp_family keyword, 6, 85,

Page 182 - Disabling a Functional Block

250 Index F far keyword, 7, 181, 182 fastaccess keyword, 205 fatal error diagnostic from compiler, 238 fblock keyword

Page 183 - System Errors

Neuron C Programmer’s Guide 251 periodic, 154, 158 restrictions, 165 semaphore, 161 sharing data, 161 sources, 153 task, 155 timer/counter, 1

Page 184

252 Index msg_send( ) function, 120, 125, 130, 144, 197 msg_succeeds event, 21, 131, 141, 148 comparison with resp_ar

Page 185

Neuron C Programmer’s Guide 253 O object files, 222, 223 offchip keyword, 7, 179, 181, 183, 185 off-chip memory use of, 176 offline event, 18

Page 186 - EEPROM Use

254 Index comparison with msg_succeeds event, 141 resp_free( ) function, 144 resp_in object, 139 addr field, 198 defi

Page 187

Neuron C Programmer’s Guide 255 domain. See domain table network variable configuration, 188 tag keyword, 121 tasks, 16, 18, 47 order of exec

Page 189 - Memory Regions

Neuron C Programmer’s Guide 15 2 Focusing on a Single Device This chapter describes the Neuron C event scheduler and I/O objects. The conce

Page 190 - Memory Areas

16 Focusing on a Single Device What Happens on a Single Device? In this chapter, you begin to learn about programming

Page 191

Neuron C Programmer’s Guide 17 In this example above, when the led_timer application timer (definition not shown in this example) expires, th

Page 192 - Default Memory Usage

Neuron C Programmer’s Guide iii Welcome This guide describes how to write programs using the Neuron® C Version 2.2 language. Neuron C is a pr

Page 193 - Declarations)

18 Focusing on a Single Device event This expression is either a predefined event (see the following section) or any

Page 194

Neuron C Programmer’s Guide 19 Predefined Event Where Described in This Manual msg_arrives Chapter 6 msg_completes Chapter 6 msg_fails Chapt

Page 195

20 Focusing on a Single Device io_changes). These operators are of equal precedence with each other, but they are mu

Page 196 - Use of Flash Memory

Neuron C Programmer’s Guide 21 msg_succeeds msg_fails resp_arrives Most network events, except resp_arrives, are enqueued only if the Neuron

Page 197

22 Focusing on a Single Device User-Defined Events A user-defined event can contain assignments and function calls.

Page 198

Neuron C Programmer’s Guide 23 Letter names shown above are used for the clauses in Figure 1 and the following narration of events. This sho

Page 199

24 Focusing on a Single Device when clause selected evaluates to FALSE, its task is ignored and the scheduler resumes

Page 200 - Address Table

Neuron C Programmer’s Guide 25 void f() { /* body */ } g (a,b) int a; int b; { /* body */ } Although Neuron C can create prototypes, it do

Page 201 - Alias Table

26 Focusing on a Single Device initial-value An optional initial value to be loaded into the timer on power-up or re

Page 202 - Allocating Buffers

Neuron C Programmer’s Guide 27 } If your program has multiple timers, you must include a specific check for each timer so that the expiration

Page 203 - Buffer Size

iv Related Documentation The following manuals are available from the Echelon Web site (www.echelon.com) and provide additional information that can h

Page 204 - Buffer Counts

28 Focusing on a Single Device objects can also be linked to Neuron C events, because changes in I/O often affect tas

Page 205

Neuron C Programmer’s Guide 29 magtrack1 serial wiegand Serial Input/Output Model Types i2c neurowire sci spi • Parallel I/O Models a

Page 206 - Outgoing Network Buffers

30 Focusing on a Single Device options Optional I/O parameters, dependent on the chosen type for the I/O object. Th

Page 207 - Incoming Application Buffers

Neuron C Programmer’s Guide 31 Example 1: Thermostat Interface This thermostat measures the resistance of a thermistor by measuring the puls

Page 208 - (20, 21, 22, 24, 26, 30, 34

32 Focusing on a Single Device // Uses a thermistor to measure temperature, and a // quadrature encoder to enter setp

Page 209 - (20, 21, 22, 24, 26, 30)

Neuron C Programmer’s Guide 33 desiredTemp = max(DESIRED_TEMP_MIN, desiredTemp); } //////////////////////////////////////////////////////

Page 210

34 Focusing on a Single Device value through the built-in variable input_value. Dimmer SwitchZero-CrossingDetector11

Page 211 - Neuron Chip

Neuron C Programmer’s Guide 35 // since a lower value means more light. currentBrightness -= input_value; // Look for underflow

Page 212 - Template File

36 Focusing on a Single Device Neuron ChipIO_8IO_9IO_2+5VC4.01F470R103 Digit LED DisplayMulti-CharacterLED Display Dr

Page 213

Neuron C Programmer’s Guide 37 • Triac pulse timer. Timer used to generate pulses for the stretchedtriac and triac output objects. The fol

Page 214 - Initialization Actions

Neuron C Programmer’s Guide v Table 1. Typographic Conventions Typeface or Symbol Used for Example boldface type keywords literal characters

Page 215 - Be Aware of Library Usage

38 Focusing on a Single Device Series 3100 device with a 10 MHz clock, the expected duration of a millisecond timer i

Page 216 - Observe Declaration Order

Neuron C Programmer’s Guide 39 treats as 820 microsecond ticks. This means that a timer duration is actually 0.999 times the specified durat

Page 217

40 Focusing on a Single Device Time started here.H1E1L1H2E2L2E1Timer expires in this range.Second iteration of timer

Page 218 - Use Function Calls Liberally

Neuron C Programmer’s Guide 41 count A value between 1 and 33,333. See the Neuron C Reference Guide for the formula used in determining the

Page 220

Neuron C Programmer’s Guide 43 3 How Devices Communicate Using Network Variables This chapter discusses how LONWORKS devices communicate wit

Page 221 - Using the Link Map

44 How Devices Communicate Using Network Variables Major Topics LONWORKS devices communicate with other LONWORKS devi

Page 222

Neuron C Programmer’s Guide 45 • Changeable-Type Network Variables on page 68 describes how to implement network variables that allow their t

Page 223

46 How Devices Communicate Using Network Variables Figure 6. Sample Development Network with Five Devices The declar

Page 224 - Common Syntax

Neuron C Programmer’s Guide 47 Note: This discussion uses the terms writer device and reader device. A writer device is a device that write

Page 226 - Common Set of Basic Commands

48 How Devices Communicate Using Network Variables After the device design is complete, you specify connections betwe

Page 227 - Neuron C Compiler

Neuron C Programmer’s Guide 49 network input SNVT_temp nviTemp; network output SNVT_switch nvoHeater; network output int nvoCurrentTemp; Exam

Page 228 - Neuron Linker

50 How Devices Communicate Using Network Variables Figure 7. A Simple Closed-Loop System Use of the is_bound( ) Func

Page 229 - Neuron Exporter

Neuron C Programmer’s Guide 51 Network Variable Events Chapter 2, Focusing on a Single Device, on page 15, introduced the event scheduling me

Page 230

52 How Devices Communicate Using Network Variables io_out(ioLED, nviLampState.state); } In the following example, wh

Page 231 - Neuron Librarian

Neuron C Programmer’s Guide 53 heater_failed = FALSE; // heater device received update } The nv_update_completes Event The nv_up

Page 232 - Neuron C Function Libraries

54 How Devices Communicate Using Network Variables Declaring Synchronous Network Variables To declare a synchronous n

Page 233

Neuron C Programmer’s Guide 55 Preemption Mode The scheduler enters preemption mode when a synchronous output network variable update occurs

Page 234 - Definitions

56 How Devices Communicate Using Network Variables 2 Check for the failure and the success events (nv_update_fails

Page 235 - Disadvantages of a Library

Neuron C Programmer’s Guide 57 The reader device makes its request through the poll( ) function. The syntax is shown below: poll ([network-v

Page 236

Neuron C Programmer’s Guide vii Table of Contents Welcome...

Page 237

58 How Devices Communicate Using Network Variables mtimer tDelayedPolling; /////////////////////////// Tasks ///////

Page 238

Neuron C Programmer’s Guide 59 Example: A lamp and switch example could also be written to use explicit polling of the switch network variabl

Page 239

60 How Devices Communicate Using Network Variables IO_4 input bit ioButton = BUTTON_UP; ///////////////////////////

Page 240

Neuron C Programmer’s Guide 61 Example: network output SNVT_temp nvoTemp; when (timer_expires(heartbeat)) { propagate(nvoTemp); } The pro

Page 241

62 How Devices Communicate Using Network Variables Initial Value Updates for Input Network Variables Many application

Page 242

Neuron C Programmer’s Guide 63 Example: network input SNVT_temp nviCurrent; network input SNVT_temp nviSetpoint; network output SNVT_volt

Page 243

64 How Devices Communicate Using Network Variables poll(nviSetpoint); } when(nv_update_occurs(nviSetpoint)) when(n

Page 244

Neuron C Programmer’s Guide 65 Monitoring Network Variables A monitoring device is a LONWORKS device that receives data from many other devic

Page 245

66 How Devices Communicate Using Network Variables Following is an example for the code on a network monitor device:

Page 246 - Providing a Large RAM Space

Neuron C Programmer’s Guide 67 Declaring Authenticated Variables and Messages For network variables, include the authenticated (or auth) keyw

Page 247

viii Fixed Timers ... 36 Scaled Timers and I/O Objects ...

Page 248

68 How Devices Communicate Using Network Variables 4 Device B compares its computed transformation with the number i

Page 249 - Neuron C Language

Neuron C Programmer’s Guide 69 You can use a changeable-type network variable to implement a generic functional block that works with differe

Page 250 - Translation (J.3.1)

70 How Devices Communicate Using Network Variables configuration property access through LW-FTP and check, in the sto

Page 251 - Identifiers (J.3.3)

Neuron C Programmer’s Guide 71 property automatically assumes the size and type of the network variable it applies to, and is governed by the

Page 252 - Characters (J.3.4)

72 How Devices Communicate Using Network Variables Validating a Type Change There are several ways that your applicat

Page 253 - Integers (J.3.5)

Neuron C Programmer’s Guide 73 If one or more type-inheriting configuration properties apply to changing configuration network variables (CPN

Page 254 - Standard)

74 How Devices Communicate Using Network Variables Your application must always support the NVT_CAT_INITIAL type cate

Page 255 - (J.3.9)

Neuron C Programmer’s Guide 75 The get_nv_length_override( ) function returns the current length of the network variable with the index speci

Page 256 - Qualifiers (J.3.10)

76 How Devices Communicate Using Network Variables of the framework provided by NodeBuilder Code Wizard. Your applic

Page 257 - Library Functions (J.3.12)

Neuron C Programmer’s Guide 77 // and allow for its use even if the target device doesn't support // system extensions. See text for de

Page 258

Neuron C Programmer’s Guide ix Instantiation of Configuration Properties ... 88 Device Propert

Page 259

78 How Devices Communicate Using Network Variables #endif // For all inheriting configuration properties tha

Page 260 - 248 Index

Neuron C Programmer’s Guide 79 // returns the current length of the given NV (in bytes) or 0xFF to // indicate that the initial type is still

Page 261

80 How Devices Communicate Using Network Variables // TODO: If needed by the application algorithm, transform

Page 262 - 250 Index

Neuron C Programmer’s Guide 81 // for details. nvoVolt = nvLocal.xInitial; } // bConversionOK } // SetCurrent()

Page 264 - 252 Index

Neuron C Programmer’s Guide 83 4 Using Configuration Properties to Configure Device Behavior This chapter discusses the declaration and

Page 265

84 Using Configuration Properties to Configure Device Behavior Overview A configuration property is a data item that,

Page 266 - 254 Index

Neuron C Programmer’s Guide 85 configuration file, and no events are automatically generated when a configuration property implemented within

Page 267

86 Using Configuration Properties to Configure Device Behavior configuration property, or with the entire configurati

Page 268

Neuron C Programmer’s Guide 87 in the standard.typ file, which is part of the standard resource file set included with the NodeBuilder tool.

Commentaires sur ces manuels

Pas de commentaire