Controlling non-default memory usage – Echelon Neuron C User Manual

Page 193

Advertising
background image

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 does not fit

into the available default memory, you can change the declarations of variables
or functions using special Neuron C keywords and using certain compiler

directives. These keywords and directives enable you to move the variables or

functions to other locations in memory. The eeprom, far, offchip, onchip, ram,
and uninit special keywords are described below.
Direct memory reads and writes (by the application program) to data in the

EENEAR and RAMNEAR areas take advantage of special addressing modes in
the Neuron Chip and Smart Transceiver that generate more efficient code (fewer

bytes per instruction and fewer cycles per read or write). However, indirect
memory access (by a pointer) is the same for near and far memory areas.

eeprom Keyword (for Functions and Data
Declarations)

Functions and const data are located in ROM by default. When ROM is full, or

when no ROM is available, the remaining functions and const data are placed in
the EECODE areas, first in the offchip EECODE area, then in the onchip

EECODE area. However, functions and const data can be explicitly redirected

from the ROM area to the EECODE area of memory by including the eeprom
keyword in the function definition or data declaration. For example:

eeprom int fn() { ... statements ... }
eeprom const type varname = {inits};

The eeprom keyword is useful for functions that might be occasionally but rarely

changed after installation by a network tool. Likewise, a network tool would be

able to modify a const data structure stored in EEPROM that might be used for
calibration, or other configuration.
This keyword also allows the program to indicate variables whose values are

preserved across power outages by locating the variables in EENEAR rather than
in RAMNEAR. However, EEPROM memory has a limited capability to accept

changes. See the EEPROM vendor’s data sheets for a discussion of the limit to

the number of writes that a particular EEPROM can support.

You can redirect variables from the RAMNEAR area to the EENEAR area of

memory by including the eeprom keyword in the declaration, as described earlier.
For example, the following declaration moves

varname

to the EENEAR area:

eeprom int varname;

You can direct network variables to the EENEAR area with either the eeprom or

config keyword. You can also use the far keyword with network variables similar

to the example above.

The EENEAR area is limited in size to a maximum of 255 bytes (but other factors

can limit this area further). Any additional on-chip EEPROM, and all off-chip

EEPROM are considered EEFAR areas. To move a particular variable to an
EEFAR area, see the discussions of the far, offchip, and onchip keywords below.
Initializers for eeprom class variables take effect when the application image is
loaded from an external system, such as the LonMaker Integration Tool or

another network tool. Reloading a program has the effect of reinitializing all

Advertising