フィルターのクリア

Handling pooled constants in C code generated by Embedded Coder?

18 ビュー (過去 30 日間)
Matthias Weber
Matthias Weber 2018 年 5 月 25 日
コメント済み: goerk 2020 年 3 月 6 日
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 Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by