Effacer les filtres
Effacer les filtres

Handling pooled constants in C code generated by Embedded Coder?

18 vues (au cours des 30 derniers jours)
Matthias Weber
Matthias Weber le 25 Mai 2018
Commenté : goerk le 6 Mar 2020
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

Réponses (2)

goerk
goerk le 4 Juil 2018
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 commentaires
ThomasZ
ThomasZ le 6 Mar 2020
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 le 6 Mar 2020
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')

Connectez-vous pour commenter.


Soren
Soren le 4 Juil 2018
Modifié(e) : Soren le 4 Juil 2018
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.

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by