Borrar filtros
Borrar filtros

Handling pooled constants in C code generated by Embedded Coder?

18 visualizaciones (últimos 30 días)
Matthias Weber
Matthias Weber el 25 de Mayo de 2018
Comentada: goerk el 6 de Mzo. de 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

Respuestas (2)

goerk
goerk el 4 de Jul. de 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 comentarios
ThomasZ
ThomasZ el 6 de Mzo. de 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 el 6 de Mzo. de 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')

Iniciar sesión para comentar.


Soren
Soren el 4 de Jul. de 2018
Editada: Soren el 4 de Jul. de 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.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by