Simulink Embedded Coder Zero Initialization of Local Variables Not Working
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am using Embedded Coder on Simulink Model (MATLAB 2022B). I want Local variables of generated code to be initialized to zero. I already unticked 'Remove root level I/O zero initialization' and 'Remove internal data zero initialization' so code shouldn't optimize initializations. These two settings initialize Global variables to zero, but don't initialize Local variables to zero. There is an example of generated code and how I want it to be. How can I do it? Thanks for your help.
How it is:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide;
uint16_t UnitDelay1;
...
How it should be:
void step_function(uint16_t in1, uint16_t in2)
{
uint16_t Divide = 0;
uint16_t UnitDelay1 = 0;
...
0 commentaires
Réponses (1)
Akshat Dalal
le 16 Août 2024
Modifié(e) : Akshat Dalal
le 16 Août 2024
Hi Furkan,
There can still be some other optimizations which can remove the zero-initialization code. You could either disable all optimizations, or a simpler approach would be unset the 'RemoveLocalVariableInitialization'. This would ensure no optimization removes the zero-initialization.
However, this is introduced in R2023b version of MATLAB. I would suggest you to update to R2023b or later releases to avail this feature.
0 commentaires
Voir également
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware 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!