- 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"?
조회 수: 5 (최근 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!