Contenido principal

Load Data/Code to Flash and Run from RAM on TI C2000

R2026b

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.

  1. Open the Configuration Parameters of your model, navigate to the Hardware Implementation > Build options > Linker command file, and click on the Edit button.

    Hardware Implementation pane for TI Delfino F2837xD showing Build options with linker command file path and Edit button

  2. Find the ramfuncs section as shown.

    Linker command file c28377D.cmd showing SECTIONS block with ramfuncs section highlighted

  3. 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

  4. Select the tic2000demospkg package from the Custom storage class designer.

    Custom Storage Class Designer showing tic2000demospkg package with memory section definitions on Memory Section tab

  5. 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.

    Custom Storage Class Designer Memory Section tab showing const_data_ramfuncs with pragma DATA_SECTION statement

  6. 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.

    Subsystem block parameters Code Generation tab with Memory section for execution functions set to code_ramfuncs

  7. 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.

    Parameter properties Code Generation tab showing Storage class dropdown with const_data_ramfuncs selected

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.

  1. Enter the following command in the MATLAB command window to open the Custom Storage Class Designer tool.

    cscdesigner

  2. Select the tic2000demospkg package.

    Custom Storage Class Designer showing tic2000demospkg package with Default class on Custom Storage Class tab

  3. Go to the Memory Section tab and create a new memory section. Enter the pragma statement in the Pre statement section:

    Custom Storage Class Designer Memory Section tab showing align512 section with pragma DATA_ALIGN Pre statement

  4. Click on the Custom Storage Class tab, create a new custom storage class, and select the previously created memory section.

    Custom Storage Class Designer Custom Storage Class tab showing AlignMemory512 class with Memory section set to align512

  5. Click Apply and close the window. Save the package when prompted. You may need to restart MATLAB to use the new storage class.

  6. If you are using MATLAB version R2020a and before:

    1. Apply your new Storage class to tic2000demospkg.Signal and tic2000demospkg.Parameter objects and in block parameters where required.

      Data Store Memory block parameters with Signal object class tic2000demospkg.Signal and Storage class AlignMemory512

    2. Click OK.

  7. 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

| | |

Topics