Variable initialization, Neuron c declarations – Echelon Mini FX User Manual
Page 81

68 Developing
Device
Applications
Variable Initialization
Initialization of variables occurs at different times for different classes. The const
variables, except for network variables, must be initialized. Initialization of const
variables occurs when the application image is first loaded into the Neuron Chip or
Smart Transceiver. The const ram variables are placed in off-chip RAM that must be
non-volatile. The eeprom and config variables are also initialized at load time, except
when the uninit class modifier is included in these variable definitions.
Automatic variables cannot be declared const because Neuron C does not implement
initializers in declarations of automatic variables.
Global RAM variables are initialized at reset (specifically when the device is reset or
powered up). By default, all global RAM variables (including static variables) are
initialized to zero at this time.
Initialization of I/O objects, input network variables (except for eeprom, config,
config_prop, or const network variables), and timers also occurs at reset. Zero is the
default initial value for network variables and timers.
Local variables (except static ones) are not automatically initialized, nor are their values
preserved when the program execution leaves the local scope.
Neuron C Declarations
The Neuron C Version 2.2 programming language and ANSI C both support the
following declarations listed in Table 5.1:
Table 5.1 ANSI C and Neuron C Declarations
Declaration Example
Simple data items
int a, b, c;
Data types
typedef unsigned long ULONG;
Enumerations
enum hue {RED, GREEN, BLUE};
Pointers
char *p;
Functions
int f(int a, int b);
Arrays
int a[4];
Structures and unions
struct s {
int field1;
unsigned field2 : 3;
unsigned field3 : 4;
};
The Neuron C Version 2.2 programming language also supports the following
declarations listed in Table 5.2:
Table 5.2 Neuron C Declarations
Declaration Example
I/O objects
IO_0 output oneshot relay_trigger;
Timers
mtimer led_on_timer;
Network variable
network input SNVT_temp nviTemperature;