Variable initialization, Neuron c declarations – Echelon Neuron C User Manual

Page 19

Advertising
background image

Neuron C Programmer’s Guide

7

uninit

When combined with the eeprom keyword (see below), specifies that

the EEPROM variable is not initialized or altered on program load or
reload over the network.

The following Neuron C keywords allow you to direct portions of application code

and data to specific memory sections:

• eeprom
• far
• offchip

(only for Neuron Chips and Smart Transceivers

with

external

memory)

• onchip
• ram

(only for Neuron Chips and Smart Transceivers

with

external

memory)

These keywords are particularly useful on the Neuron 3150 Chip and 3150 Smart
Transceivers, because a majority of the address space for these parts is mapped

off chip. See

Using Neuron Chip Memory

on page 176 for a more detailed

description of memory usage and the use of these keywords.

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. Therefore, 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 (that is, 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 to zero costs no extra code space, as

it is a firmware feature.
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

Both ANSI C and Neuron C support the declarations listed in Table 2.

Table 2. ANSI C and Neuron C Declarations

Declaration

Example

Simple data items

int a, b, c;

Advertising