- Goto Configuration Parameters -> Optimization -> Signals and Parameters
- Disable the option Enable local block outputs
How to change C-coder settings to create static variables in the "Model step function"?
4 ビュー (過去 30 日間)
古いコメントを表示
I'm using the Simulink C-Coder to generate my model in C and use it in a micro controller. When I run the generated C-code I get a "stack overflow", and this is because of the many variables in /*Model step function*/. Is there a way to change the coder settings, so that the variables in the step function are declared as static variables?
This is how the code is generated:
/* Model step function */
void Battery_state_algorithms_v1_step(void)
{
/* local block i/o variables */
real32_T rtb_Z1[180];
real32_T rtb_Z2[180];
real32_T rtb_Z3[180];
.
.
.
}
This is how I would like to have it:
/* Model step function */
void Battery_state_algorithms_v1_step(void)
{
/* local block i/o variables */
static real32_T rtb_Z1[180];
static real32_T rtb_Z2[180];
static real32_T rtb_Z3[180];
.
.
.
}
Thanks!
0 件のコメント
回答 (2 件)
TAB
2013 年 1 月 29 日
There is no configuration option available to change the storage class specifier of variables in generated step function.
Instead you can try to minimize the generation of function local variables using optimization setting.
In this way, all the intermidiate data will be generated as global variables whenever possible.
2 件のコメント
Enrique Martí
2016 年 10 月 21 日
You can directly place a limit on stack size using *Configuration Parameters -> Optimization -> Signals and Parameters -> Maximum stack size (in bytes). See this link.
If you prefer to do it from command, take your simulink config structure and change it this way ( taken from here):
<cfg_structure>.set_param('MaxStackSize', '512');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!