Load Data/Code to Flash and Run from RAM on TI C2000
The TI compiler simplifies the process of automatically allocating RAM data using the ramfuncs attribute. This attribute facilitates seamless integration of RAM data allocation within the flash memory.
The shipping *.cmd (Linker command file) file of a specific processor already has allocation of sections of flash to store RAM data.
Open the Configuration Parameters of your model, navigate to the Hardware Implementation > Build options > Linker command file, and click on the Edit button.
Find the ramfuncs section as shown.
The custom storage class package tic2000demospkg in the C2000 Microcontroller Blockset enables loading parameters/routines onto flash memory and executing them from RAM using the
ramfuncs
section. To confirm the presence of these built-in storage classes, run the following command in the MATLAB command window:cscdesigner
Select the tic2000demospkg package from the Custom storage class designer.
In the Memory Sections tab, find sections named code_ramfuncs and const_data_ramfuncs which can be used to store code and data in the ROM but copy them into RAM during execution.
To place a subsystem in the ramfuncs section, right-click on the subsystem, select Block Parameters and under the Code Generation tab, select the appropriate memory section as shown below.
Similarly, to allocate a Simulink parameter to ramfuncs section, type tic2000demospkg.Parameter in the MATLAB command prompt:
tic2000demospkg.Parameter
Double-click on the parameter in the workspace and select const_data_ramfuncs.
Custom Memory Section for TI C2000
You can create a custom memory section using the Custom Storage Class Designer. The following steps describe on how to align a signal buffer to start on a 512-byte boundary.
Enter the following command in the MATLAB command window to open the Custom Storage Class Designer tool.
cscdesigner
Select the tic2000demospkg package.
Go to the Memory Section tab and create a new memory section. Enter the pragma statement in the Pre statement section:
Click on the Custom Storage Class tab, create a new custom storage class, and select the previously created memory section.
Click Apply and close the window. Save the package when prompted. You may need to restart MATLAB to use the new storage class.
If you are using MATLAB version R2020a and before:
Apply your new Storage class to tic2000demospkg.Signal and tic2000demospkg.Parameter objects and in block parameters where required.
Click OK.
For R2020b and beyond: In R2020b, the Code Mappings Editor became the primary location to configure model data elements for code generation. For more information, see Code Mappings Editor – C (Simulink Coder)
See Also
Overview of CLA Configuration for C2000 Processors Using Subsystem | Overview of Creating a Model and Generating Executable for C2000 Processors | Enhance Code Execution Speed in TI C2000 Simulink Applications | Measuring Code Execution Time on TI C2000 using Custom Code Blocks