필터 지우기
필터 지우기

Simulink Embedded Coder Zero Initialization of Local Variables Not Working

조회 수: 15 (최근 30일)
FURKAN TULUK
FURKAN TULUK 2024년 8월 14일 8:19
편집: Akshat Dalal 2024년 8월 16일 10:12
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;
...

답변 (1개)

Akshat Dalal
Akshat Dalal 2024년 8월 16일 10:12
편집: Akshat Dalal 2024년 8월 16일 10:12
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.

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by