How to automatically add some code content at any place in the code generated by simulink
1 view (last 30 days)
Show older comments
simulink code:
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* '<S35>/Constant127'
* '<S35>/Constant90'
* '<S104>/Constant127'
* '<S104>/Constant90'
* '<S151>/Constant127'
* '<S151>/Constant90'
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: '<S9>/Constant15' */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: '<S9>/Constant17' */
Object Code:
#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED
#include "ASW_MemMap.h"
/* Const memory section */
/* Definition for custom storage class: Const */
const uint8_T SFCMM_ABSFunc_Active = 1U;/* Referenced by:
* '<S35>/Constant127'
* '<S35>/Constant90'
* '<S104>/Constant127'
* '<S104>/Constant90'
* '<S151>/Constant127'
* '<S151>/Constant90'
*/
const uint8_T SFCMM_AEBFuncConfig_Open = 1U;/* Referenced by: '<S9>/Constant15' */
const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: '<S9>/Constant17' */
#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED
include "ASW_MemMap.h"
how to add “#define ASW_QM_COM_MODULE_START_SEC_CONST_UNSPECIFIED #include "ASW_MemMap.h” and“#define ASW_QM_COM_MODULE_STOP_SEC_CONST_UNSPECIFIED include "ASW_MemMap.h"” in front of "/* Const memory section */ " and
behind "const uint8_T SFCMM_AEBFuncSwitch_Open = 1U;/* Referenced by: '<S9>/Constant17' */"
0 Comments
Answers (1)
Shivam
on 23 Apr 2024
Hi Phlips,
From the information provided, I understand that you want to add custom code to the code generated using Simulink Coder.
To achieve this, you can use the 'Model Source' block, where you can specify the code for the code generator to add near the top or bottom of the source file. The 'Model Source' block can be found in the "Simulink Coder -> Custom Code" library. You can double-click on the block and add your custom code in the "Top of Model Source" or "Bottom of Model Source" section.
Following code generation, you can open the generated source file and find the custom code statements near the top/bottom of the file, depending upon the section where you put the code.
You can refer to the following documentation to learn more about the 'Model Source' block:
I hope it helps.
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!