Designing Your Model: Model-Code Correspondence : Statecharts : Timeout Implementation : Special Requirements for OSEK-targeted Applications

Special Requirements for OSEK-targeted Applications

OSEK-targeted applications have special requirements:

1.
For each counter, an overflow task named <counter_name>_OVERFLOW is generated. This includes the task declaration (found in os_decl.h) and body code (found in glob_func.c).
2.
In each task, there is overflow management provided only for the Timeout variables that see the specific counter.
3.
For each counter, an alarm named <counter_name>_ALARM is generated. This includes the alarm declaration (found in os_decl.h) and installation (found in macro_def.h). In the macro_def.h file, a new macro is generated:

#define SET_ADDITIONAL_OVERFLOW_ALARMS() {\
SetAbsAlarm(<counte_name>_ALARM, 0,
OSMAXALLOWEDVALUE);\
}

This macro installs all the overflow alarms that activates the overflow tasks. A call to this macro is in the file <profile-name>.c after the installation of the SYS_TIMER_ALARM (formerly known as SYS_TIME_OVERFLOW).

Compare this to non-OSEK implementations:

1.
For each counter, an overflow function named on<counter_name>_OVERFLOW is generated. In each task, overflow management is provided only for the Timeout variables that see that specific counter.
2.
IMPORTANT - there is no call to these functions in the generated code. Therefore, in order to use them, additional code should be added by the developer that decides when to call these functions (on overflow), possibly in usercode.c.
Note:
Set from within the Code Generation Profile Editor. Use Options > Settings > General > Timeout Variable Type.
The goal is to have a variable that is bigger then the counter, thus avoiding the “value overflow” problem.