Real Time Workshop - variables initialization

2 visualizaciones (últimos 30 días)
p fontaine
p fontaine el 29 de En. de 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.

Respuesta aceptada

MarkB
MarkB el 31 de En. de 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.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by