Echelon Neuron C Manual de usuario

Busca en linea o descarga Manual de usuario para Software Echelon Neuron C. Echelon Neuron C User Manual Manual de usuario

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 268
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente

Indice de contenidos

Pagina 1 - C Programmer’s Guide

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

Pagina 2

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

Pagina 3 - Audience

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

Pagina 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

Pagina 5

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

Pagina 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

Pagina 7 - Table of Contents

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

Pagina 8

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

Pagina 9

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

Pagina 10

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

Pagina 11

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

Pagina 12

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

Pagina 13

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

Pagina 14 - What Is Neuron C?

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

Pagina 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

Pagina 16 - Neuron C Integer Constants

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

Pagina 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

Pagina 18 - Neuron C Storage Classes

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

Pagina 19 - Neuron C Declarations

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

Pagina 20

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

Pagina 21 - Configuration Properties

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

Pagina 22

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

Pagina 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

Pagina 24

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

Pagina 25 - Functions

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

Pagina 26

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

Pagina 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

Pagina 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

Pagina 29 - When Statement

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

Pagina 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

Pagina 31

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

Pagina 32 - Event Processing

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

Pagina 33 - Reset Event

116 Using Functional Blocks to Implement a Device Interface

Pagina 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

Pagina 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

Pagina 36 - Function Prototypes

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

Pagina 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

Pagina 38 - The timer_expires Event

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

Pagina 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

Pagina 40 - I/O Object Types

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

Pagina 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

Pagina 42 - Device Self-Documentation

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

Pagina 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

Pagina 44

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

Pagina 45

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

Pagina 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.

Pagina 47

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

Pagina 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

Pagina 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

Pagina 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

Pagina 51 - Repeating Timers

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

Pagina 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

Pagina 53 - EEPROM Write Timer

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

Pagina 54

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

Pagina 55 - Network Variables

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

Pagina 56 - Major Topics

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

Pagina 57

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

Pagina 58

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

Pagina 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

Pagina 60

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

Pagina 61 - Connecting Network Variables

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

Pagina 62

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

Pagina 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

Pagina 64 - Neuron C Reference

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

Pagina 65 - Preemption Mode

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

Pagina 66

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

Pagina 67 - Variables

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

Pagina 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

Pagina 69

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

Pagina 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

Pagina 71

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

Pagina 72

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

Pagina 73

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

Pagina 74

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

Pagina 75

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

Pagina 76

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

Pagina 77 - Monitoring Network Variables

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

Pagina 78 - Authentication

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

Pagina 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

Pagina 80

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

Pagina 81

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

Pagina 82

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

Pagina 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

Pagina 84 - Validating a Type Change

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

Pagina 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

Pagina 86 - Processing a Size Change

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

Pagina 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

Pagina 88

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

Pagina 89

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

Pagina 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

Pagina 91

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

Pagina 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

Pagina 93 - } // SetCurrent()

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

Pagina 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

Pagina 95 - Configure Device Behavior

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

Pagina 96

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

Pagina 97 - ONWORKS file transfer

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

Pagina 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

Pagina 99

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 104 - Properties

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

Pagina 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

Pagina 106

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

Pagina 107 - Instantiation

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

Pagina 108

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

Pagina 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

Pagina 110

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

Pagina 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

Pagina 112

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

Pagina 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

Pagina 114 - Overview

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

Pagina 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

Pagina 116

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

Pagina 117

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

Pagina 118 - The Director Function

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

Pagina 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

Pagina 120

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

Pagina 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

Pagina 122

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

Pagina 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

Pagina 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

Pagina 125

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

Pagina 126

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

Pagina 127 - Behavior

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

Pagina 128

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

Pagina 129 - Application Messages

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

Pagina 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

Pagina 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

Pagina 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

Pagina 133 - Management

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

Pagina 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

Pagina 135

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

Pagina 136 - Block Transfers of Data

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

Pagina 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

Pagina 138 - The msg_arrives Event

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

Pagina 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

Pagina 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

Pagina 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

Pagina 142 - Explicit Addressing

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

Pagina 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

Pagina 144

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

Pagina 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

Pagina 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

Pagina 147

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

Pagina 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

Pagina 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

Pagina 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

Pagina 151 - Format of a Response

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

Pagina 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

Pagina 153

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 158 - Scheduler Reset Mechanism

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

Pagina 159 - Interrupts

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

Pagina 160 - Scheduler Example

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

Pagina 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

Pagina 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

Pagina 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

Pagina 164 - Wink Event

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

Pagina 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

Pagina 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

Pagina 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

Pagina 169

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

Pagina 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

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

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

Pagina 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

Pagina 173

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

Pagina 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

Pagina 175

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

Pagina 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

Pagina 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

Pagina 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

Pagina 180 - Error Handling

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

Pagina 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,

Pagina 182 - Disabling a Functional Block

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

Pagina 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

Pagina 184

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

Pagina 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

Pagina 186 - EEPROM Use

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

Pagina 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

Pagina 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

Pagina 190 - Memory Areas

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

Pagina 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

Pagina 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

Pagina 193 - Declarations)

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

Pagina 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

Pagina 195

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

Pagina 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

Pagina 197

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

Pagina 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

Pagina 199

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 205

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

Pagina 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

Pagina 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

Pagina 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

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

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

Pagina 210

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

Pagina 211 - Neuron Chip

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

Pagina 212 - Template File

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

Pagina 213

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

Pagina 214 - Initialization Actions

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

Pagina 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

Pagina 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

Pagina 217

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

Pagina 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

Pagina 220

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

Pagina 221 - Using the Link Map

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

Pagina 222

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

Pagina 223

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

Pagina 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

Pagina 226 - Common Set of Basic Commands

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

Pagina 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

Pagina 228 - Neuron Linker

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

Pagina 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

Pagina 230

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

Pagina 231 - Neuron Librarian

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

Pagina 232 - Neuron C Function Libraries

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

Pagina 233

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

Pagina 234 - Definitions

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

Pagina 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

Pagina 236

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

Pagina 237

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

Pagina 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

Pagina 239

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

Pagina 240

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

Pagina 241

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

Pagina 242

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

Pagina 243

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

Pagina 244

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

Pagina 245

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

Pagina 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

Pagina 247

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

Pagina 248

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

Pagina 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

Pagina 250 - Translation (J.3.1)

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

Pagina 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

Pagina 252 - Characters (J.3.4)

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

Pagina 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

Pagina 254 - Standard)

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

Pagina 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

Pagina 256 - Qualifiers (J.3.10)

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

Pagina 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

Pagina 258

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

Pagina 259

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

Pagina 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

Pagina 261

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

Pagina 262 - 250 Index

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

Pagina 264 - 252 Index

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

Pagina 265

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

Pagina 266 - 254 Index

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

Pagina 267

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

Pagina 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.

Comentarios a estos manuales

Sin comentarios