Echelon Neuron C Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Software Echelon Neuron C. Echelon Neuron C User Manual Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 268
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes

Resumo do Conteúdo

Página 1 - C Programmer’s Guide

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

Página 2

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

Página 3 - Audience

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

Página 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

Página 5

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

Página 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

Página 7 - Table of Contents

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

Página 8

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

Página 9

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

Página 10

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

Página 11

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

Página 12

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

Página 13

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

Página 14 - What Is Neuron C?

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

Página 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

Página 16 - Neuron C Integer Constants

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

Página 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

Página 18 - Neuron C Storage Classes

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

Página 19 - Neuron C Declarations

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

Página 20

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

Página 21 - Configuration Properties

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

Página 22

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

Página 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

Página 24

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

Página 25 - Functions

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

Página 26

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

Página 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

Página 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

Página 29 - When Statement

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

Página 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

Página 31

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

Página 32 - Event Processing

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

Página 33 - Reset Event

116 Using Functional Blocks to Implement a Device Interface

Página 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

Página 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

Página 36 - Function Prototypes

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

Página 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

Página 38 - The timer_expires Event

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

Página 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

Página 40 - I/O Object Types

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

Página 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

Página 42 - Device Self-Documentation

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

Página 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

Página 44

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

Página 45

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

Página 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.

Página 47

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

Página 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

Página 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

Página 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

Página 51 - Repeating Timers

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

Página 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

Página 53 - EEPROM Write Timer

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

Página 54

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

Página 55 - Network Variables

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

Página 56 - Major Topics

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

Página 57

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

Página 58

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

Página 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

Página 60

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

Página 61 - Connecting Network Variables

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

Página 62

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

Página 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

Página 64 - Neuron C Reference

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

Página 65 - Preemption Mode

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

Página 66

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

Página 67 - Variables

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

Página 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

Página 69

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

Página 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

Página 71

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

Página 72

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

Página 73

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

Página 74

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

Página 75

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

Página 76

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

Página 77 - Monitoring Network Variables

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

Página 78 - Authentication

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

Página 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

Página 80

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

Página 81

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

Página 82

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

Página 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

Página 84 - Validating a Type Change

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

Página 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

Página 86 - Processing a Size Change

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

Página 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

Página 88

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

Página 89

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

Página 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

Página 91

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

Página 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

Página 93 - } // SetCurrent()

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

Página 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

Página 95 - Configure Device Behavior

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

Página 96

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

Página 97 - ONWORKS file transfer

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

Página 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

Página 99

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

Página 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

Página 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

Página 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

Página 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

Página 104 - Properties

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

Página 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

Página 106

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

Página 107 - Instantiation

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

Página 108

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

Página 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

Página 110

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

Página 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

Página 112

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

Página 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

Página 114 - Overview

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

Página 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

Página 116

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

Página 117

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

Página 118 - The Director Function

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

Página 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

Página 120

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

Página 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

Página 122

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

Página 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

Página 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

Página 125

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

Página 126

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

Página 127 - Behavior

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

Página 128

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

Página 129 - Application Messages

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

Página 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

Página 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

Página 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

Página 133 - Management

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

Página 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

Página 135

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

Página 136 - Block Transfers of Data

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

Página 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

Página 138 - The msg_arrives Event

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

Página 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

Página 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

Página 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

Página 142 - Explicit Addressing

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

Página 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

Página 144

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

Página 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

Página 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

Página 147

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

Página 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

Página 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

Página 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

Página 151 - Format of a Response

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

Página 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

Página 153

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

Página 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

Página 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

Página 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

Página 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

Página 158 - Scheduler Reset Mechanism

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

Página 159 - Interrupts

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

Página 160 - Scheduler Example

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

Página 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

Página 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

Página 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

Página 164 - Wink Event

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

Página 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

Página 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

Página 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

Página 169

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

Página 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

Página 171 - )]',255min(,0max[ Zn =

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

Página 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

Página 173

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

Página 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

Página 175

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

Página 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

Página 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

Página 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

Página 180 - Error Handling

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

Página 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,

Página 182 - Disabling a Functional Block

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

Página 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

Página 184

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

Página 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

Página 186 - EEPROM Use

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

Página 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

Página 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

Página 190 - Memory Areas

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

Página 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

Página 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

Página 193 - Declarations)

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

Página 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

Página 195

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

Página 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

Página 197

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

Página 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

Página 199

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

Página 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

Página 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

Página 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

Página 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

Página 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

Página 205

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

Página 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

Página 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

Página 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

Página 209 - (20, 21, 22, 24, 26, 30)

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

Página 210

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

Página 211 - Neuron Chip

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

Página 212 - Template File

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

Página 213

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

Página 214 - Initialization Actions

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

Página 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

Página 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

Página 217

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

Página 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

Página 220

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

Página 221 - Using the Link Map

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

Página 222

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

Página 223

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

Página 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

Página 226 - Common Set of Basic Commands

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

Página 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

Página 228 - Neuron Linker

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

Página 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

Página 230

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

Página 231 - Neuron Librarian

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

Página 232 - Neuron C Function Libraries

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

Página 233

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

Página 234 - Definitions

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

Página 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

Página 236

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

Página 237

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

Página 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

Página 239

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

Página 240

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

Página 241

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

Página 242

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

Página 243

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

Página 244

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

Página 245

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

Página 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

Página 247

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

Página 248

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

Página 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

Página 250 - Translation (J.3.1)

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

Página 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

Página 252 - Characters (J.3.4)

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

Página 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

Página 254 - Standard)

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

Página 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

Página 256 - Qualifiers (J.3.10)

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

Página 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

Página 258

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

Página 259

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

Página 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

Página 261

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

Página 262 - 250 Index

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

Página 264 - 252 Index

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

Página 265

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

Página 266 - 254 Index

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

Página 267

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

Página 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.

Comentários a estes Manuais

Sem comentários