Hi,
is there a way to assign a time/performance critical subsystem (like IRQ handler) to be copied to and executed from TCM RAM on i.MX RT1064 (and not from the internal SPI Flash) ?
Thanks
Maciek
Solved! Go to Solution.
Hi @Maciek ,
1. Yes, for subsystem, you need to mark the subsystem to be treated as atomic and the function packaging option will be enabled in the Code Generation tab, and you can specify there the user defined signature and use that signature in the model header.
2. Yes, for IRQ handler you can take a look in startup_mimxrt1064.c for the IRQ handlers signatures.
I was mentioning that I am looking for another approach and I have another option. The subsystems, in Code generation tab have the below options:
The problem here is how to add a custom section in that drop down. And I came across something that is called custom storage class designer in simulink. (https://www.mathworks.com/help/ecoder/ug/design-custom-storage-classes-and-memory-sections.html)
Default the storage classes and memory sections for a model are loaded from a package called Simulink. Type cscdesigner and will open the below window:
The Simulink package is read only, so you cannot add new memory sections, but you can create your own package. The steps I did:
- duplicate the Simulink dataclass package ( found it here for my matlab instalation c:\Program Files\MATLAB\R2020b\toolbox\simulink\simdemos\dataclasses).
- rename duplicate to +MyDataClasses (find it attached), that I placed it in the toolbox root directory and added to the matlab path)
- in command window, type cscdesigner('MyDataClasses'), and I have my custom package loaded.
- next i could add a new memory section
Then, you need to specify to the model to load the storage classes and memory section from this custom package. This is done from Embedded Coder app, Code Interface, Embedded Coder Dictionary:
I used Manage Package (Refresh to se my custom one in the drop down) - I did an Unload of the Simulink package and then Load of the MyDataClasses.
After doing all the above steps, I could see in the memory section dropdown of the subsystems my added memory section:
The option will be available for any subsystems (including the function call ones).
Hope this helps.
Best regards,
Alexandra
Hi @Maciek ,
There is a support in simulink coder to place variables and functions but using pragmas: https://www.mathworks.com/help/ecoder/ug/control-data-and-function-placement-in-memory-by-inserting-... but for ARM GCC you need to use __attribute__section.
But even with the above steps, I could not place the function system call of the IRQ handler block in a specific section(but I will continue to investigate in this direction also) so I tried something with custom code block that did the trick:
I used a Model Header custom code block with the next info:
I declared the interrupt handler specifying the attribute__section option and is placing the the handler function to be run from address 0x0 (ITC start address). The custom code will be added in the .h file of the model generated by simulink.
The name of the section got it from the linker file: MIMXRT1064xxxxA.ld.
I hope this helps.
Best regards,
Alexandra
Thanks @nxa11767 ,
to clarify:
1) in case of any subsystem (not IRQ handler) we only need to define it's name and signature in 'function packaging' and use these in 'Model Header' block (the same as you did)
2) in case of any IRQ Handler - we need to check the name and signature of the IRQ Handler in SDK and use these in 'Model Header' block (the same as you did)
Am I right ?
Thanks
Maciek
Hi @Maciek ,
1. Yes, for subsystem, you need to mark the subsystem to be treated as atomic and the function packaging option will be enabled in the Code Generation tab, and you can specify there the user defined signature and use that signature in the model header.
2. Yes, for IRQ handler you can take a look in startup_mimxrt1064.c for the IRQ handlers signatures.
I was mentioning that I am looking for another approach and I have another option. The subsystems, in Code generation tab have the below options:
The problem here is how to add a custom section in that drop down. And I came across something that is called custom storage class designer in simulink. (https://www.mathworks.com/help/ecoder/ug/design-custom-storage-classes-and-memory-sections.html)
Default the storage classes and memory sections for a model are loaded from a package called Simulink. Type cscdesigner and will open the below window:
The Simulink package is read only, so you cannot add new memory sections, but you can create your own package. The steps I did:
- duplicate the Simulink dataclass package ( found it here for my matlab instalation c:\Program Files\MATLAB\R2020b\toolbox\simulink\simdemos\dataclasses).
- rename duplicate to +MyDataClasses (find it attached), that I placed it in the toolbox root directory and added to the matlab path)
- in command window, type cscdesigner('MyDataClasses'), and I have my custom package loaded.
- next i could add a new memory section
Then, you need to specify to the model to load the storage classes and memory section from this custom package. This is done from Embedded Coder app, Code Interface, Embedded Coder Dictionary:
I used Manage Package (Refresh to se my custom one in the drop down) - I did an Unload of the Simulink package and then Load of the MyDataClasses.
After doing all the above steps, I could see in the memory section dropdown of the subsystems my added memory section:
The option will be available for any subsystems (including the function call ones).
Hope this helps.
Best regards,
Alexandra
Thanks @nxa11767 for detailed description!
We will check the solution with custom storage classes. It is much better/cleaner than using function names/signatures.
Regards
Maciek