How can I add attributes to paramater in c- code using TLC
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
When I generate code from a simulink model, I get C-code model.c that contains the following paramater:
/* Exported block parameters */
real_T MACS_default_par = 1.0; /* Variable: MACS_default_par
* Referenced by: '<S5>/MACS_default_par'
*/
/* Block signals (auto storage) */
Which tlc file and how do I have to change is to get the code as followed:
/* Exported block parameters */
real_T MACS_default_par __attribute__((section(".calib_const"))) = 1.0;
/* Variable: MACS_default_par
* Referenced by: '<S5>/MACS_default_par'
*/
/* Block signals (auto storage) */
Thanks, Frank
0 Kommentare
Antworten (2)
Kaustubha Govind
am 24 Sep. 2012
I think you need to define a custom Data Class to achieve something like this. Not sure what version of MATLAB you are using, but the latest documentation describes two ways of doing this: Level-1 Data Classes (R2011b and older) and Level-2 Data Classes (R2012a and later).
0 Kommentare
Zouyi Yang
am 4 Nov. 2022
The customer can do this for exported global variables through the Embedded Coder Dictionary. The steps are as follows:
1. Generate a Memory Section with a Pre Statement set to __attribute__((section(".calib_const")))
Note the attribute is prepended to the declaration line, but the GCC spec on this says it's OK to be anywhere before the semicolon.
2. Once you have the Memory Section you can create a new Storage Class which uses it:
3. Create a simple model with a Simulink.Parameter and associate that parameter to the new storage class with code mappings:
4. Generate code and build. You'll get an initializer for myParam like this:
5. Check that the section was generated via the objdump.exe command:
There are 8 bytes in the memory section called ".calib_const" which correspond to the myParam variable from the Simulink model.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Coder finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!