Remove network variable names if not needed, Declare constant data properly – Echelon Neuron C User Manual

Page 213

Advertising
background image

Neuron C Programmer’s Guide

201

can consider removing the self-identification data. You can do this by specifying

the following compiler directive:

#pragma disable_snvt_si

Remove Network Variable Names if Not Needed

The Neuron C compiler places information about the names of the network

variables in the device’s program space when the compiler directive #pragma
enable_sd_nv_names appears in the program. This data consumes EEPROM.
You can remove the directive to regain one byte of EEPROM space for each

character in a network variable’s name, plus one byte for each network variable.
When the device is installed, if there is no further information available about

the network variable names, the network tool automatically assigns generic
names such as "NVI1", "NVO7", and so on.
To assist the network integrator and allow the use of intuitive, self-explanatory

names of the network variables as opposed to the generic, automatically
generated ones, provide the external interface files along with your device. The

network management software extracts the names for the network variables

from the files (.XIF or .XFB extensions), without the names consuming code space
in your device.

Declare Constant Data Properly

Use of the const or eeprom keyword in a declaration of constant data is very

important, because, without either of these keywords, the compiler assumes the
data is placed in RAM and thus the data needs to be initialized at runtime (each

time the application program is reset). This process can be very expensive in

terms of code space, it unnecessarily consumes RAM memory, and it also
unnecessarily lengthens the time it takes the application to complete its reset

processing.

Consider the following example. This example shows a

poorly declared

data table

of four bytes in length. Unfortunately, because this declaration does not use the

const keyword, the compiler places it in RAM, and it must therefore be initialized
each time the application processor resets. The executable code fragment to

initialize the array is an additional 9 bytes, and another four bytes are placed in

code space containing the initial values for the table.

Furthermore, use of RAM for the data table means that there is a chance it could

accidentally get modified by an unintentional programming error.
Example of poor declaration:

int lookup_table[4] = {1, 4, 7, 13};

The proper declaration of the data table only consumes four bytes of read-only

memory (code space) for the data values themselves.
Example of proper declaration:

const int lookup_table[4] = {1, 4, 7, 13};

Advertising