Real Time Workshop - variables initialization

1 vue (au cours des 30 derniers jours)
p fontaine
p fontaine le 29 Jan 2011
For Simumink blocks with an internal state (such as as unit delay, discrete time integrator, etc ...) the code generated for initialization differs depending on the numerical value of the initial conditions. If the initial condition is zero no initialization code is produced, while if it is not zero some initialization code is produced. Why ? This may cause troubles if the used C compiler does not force zero initialization. In such a case random initialized variables may occur.

Réponse acceptée

MarkB
MarkB le 31 Jan 2011
The "Optimization" section of the "Configuration Parameters" has several optimizations related to removing zero initializations. If you disable these optimizations, it should generate initialization code consistently, regardless of which numeric values are used.
With the optimizations enabled, most initialization code is removed, except for non-zero values, or initializations that occur in "conditionally-executed subsystems" (e.g. enabled subsystems). The general idea is that many embedded systems zero-out RAM at power-on, making explicit zero-initialization redundant. However, these conditionally-executed subsystems may need to be reset independently of a power-on condition meaning that they are not redundant.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by