Example: Accessing Non-Volatile Variables

The following module with several non-volatile variables is added to an SWC.

An NVData interface with several elements is also added to the SWC. NV-Data mapping is performed. The Auto-Mapping button with %NVVARIABLE.NAME% pattern maps array, log, and Rec_outer. cont_I is manually mapped to the NVData interface element cont, cont_I remains unmapped, and matrix is mapped to the the NVData interface element matrix. The result is shown below.

With that mapping, the following C code is generated for the module. Effects of the mapping are set in bold.

FUNC(void, SWC_NVexample_CODE) MODULE_NVVAR_IMPL_process (void)

{

/* temp. variables */

VAR(sint32, AUTOMATIC) _t1sint32;

/* process: sequence call #5 */

if (Rte_IRead_runnable_NVData_Intf_log())

{

/* If-block: sequence call #5/Then #1 */

_t1sint32 = (_cont_L /2) + (Rte_IRead_runnable_NVData_Intf_cont() /2);

_Out_cont = ((_t1sint32 >= -1073741824) ? (((_t1sint32 <=1073741823L) ? (_t1sint32 * 2) :2147483647L)) : (sint32)SINT32_MIN);

}/* end if */

/* process: sequence call #15 */

_Out_limitInt =Rte_IRead_runnable_NVData_Intf_array()[_out_x];

/* process: sequence call #20 */

memcpy(_Out_matrix_REF_ ,Rte_IRead_runnable_NVData_Intf_matrix() ,sizeof(uint8_3[4]));

/* process: sequence call #25 */

_Out_log =Rte_IRead_runnable_NVData_Intf_Rec_outer()->R_log;

/* process: sequence call #30 */

_Out_cont =Rte_IRead_runnable_NVData_Intf_Rec_outer()->Rec_inner.Ri_cont;

}