Simulink Code Generation Omitting variable declarations/usage, what configuration controls this?

1 view (last 30 days)
I believe this is simply a configuration setting in the Optimization section, but I have yet to find out where. I have a model that is generating an embedded C code output using the TI C2000 Toolchain, and so far it works well. One thing I noticed however, is that variables that are set anywhere inside the state block or anywhere during the transitions get ommited from the code generation. I have a Stateflow chart here:
And I would like it to output something similar to the following:
switch (rtDW.is_c1_ExampleProj) {
case IN_Case0:
rtDW.TestFlg = 0;
rtDW.intH = 0;
if (0 > rtDW.VinOK) {
rtDW.is_c1_ExampleProj = IN_Case1;
} else {
rtDW.Error = 0;
rtDW.is_c1_ExampleProj = IN_Case0;
}
break;
%% Remaining cases below
A few things to note with the example, data_bus(29) is set to zero right now which is why it is "if (0 < vinOK)", all other values are set as Data Store values and are declared in the upper level model. Based on the structure of this stateflow chart, I should get exactly what I have coded. However, for some reason whenever I generate the code, I get the same code EXCEPT rtDW.TestFlg and rtDW.intH are ommited. I found out that unless they are used in one of the conditional statements on the chart, the compiler will ommit them. Obviously, that means I need to be actually using them, but I want to know if there is anywhere in the configuration that would stop the compiler from doing this? I'm trying to build this model in sections, and it is difficult to do that when values that are not currently being used are being ommited
I dont have the option for my release in the tags, but I am running on R2021b

Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!