Handling pooled constants in C code generated by Embedded Coder?

19 次查看(过去 30 天)
Hi,
can you please guide me to the part of the documentation relevant to pooling of constants in the code generated by Embedded Coder? I could not find anyhting neither in the Getting started guide, nor in the reference.
We may be facing issues when generating code for two separate models and integrating them into a common framework.
Is there a rule in the naming for the pooled constants/ constant parameters (in const_params.c)? How can this pooling be switched off? Can collissions occur?
Kind regards,
Matthias

回答(2 个)

goerk
goerk 2018-7-4
I had a similar problem and found a solution in the "Simulink Coder User's Guide"
Excerpt from the "Simulik Coder User's Guide":
Suppress Shared Constants in the Generated Code
You can choose whether or not the code generator produces shared constants and shared functions. You may want to be able to keep the code and data separate between subsystems, or you may find that sharing constants results in a memory shortage during code generation.
You can change this parameter programmatically using the parameter GenerateSharedConstants with set_param and get_param
>> set_param('rtwdemo_throttlecntrl','GenerateSharedConstants','off')
  2 个评论
ThomasZ
ThomasZ 2020-3-6
Hello,
this command can not be used, when using a configuration set (conf data in .mat).
Strange thing is, I can not find an equivalent setting in the configuration parameters.
Is the setting named differently there?
goerk
goerk 2020-3-6
In the .mat file there has to be a variable of type 'Simulink.ConfigSet'.
Lets asume this variable has the name 'cs';
You have to load the .mat file and change the parameter.
load('config.mat')
set_param(cs,'GenerateSharedConstants','off')

请先登录,再进行评论。


Soren
Soren 2018-7-4
编辑:Soren 2018-7-4
Hi.
I have had the same problem. Code generating two independent models and include them into legacy code. The generated code compiled individualy fine, but when linked together the same error came.
It is proberbly because you have enabled inline optimazationa and are using a lookup table.
A solution is to post-process the generated code and give the const in const_params.c, that gives the linker error new names, because I do not think the name can be set anywhere in the configuration.

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by