SPNA237A April   2018  – October 2026 RM41L232 , RM42L432 , RM44L520 , RM44L920 , RM46L430 , RM46L440 , RM46L450 , RM46L830 , RM46L840 , RM46L850 , RM46L852 , RM48L530 , RM48L540 , RM48L730 , RM48L740 , RM48L940 , RM48L950 , RM48L952 , RM57L843 , TMS570LC4357 , TMS570LC4357-EP , TMS570LC4357-SEP , TMS570LS0232 , TMS570LS0332 , TMS570LS0432 , TMS570LS0714 , TMS570LS0714-S , TMS570LS0914 , TMS570LS1114 , TMS570LS1115 , TMS570LS1224 , TMS570LS1225 , TMS570LS1227 , TMS570LS2124 , TMS570LS2125 , TMS570LS2134 , TMS570LS2135 , TMS570LS3134 , TMS570LS3135 , TMS570LS3137

 

  1.   1
  2.   FreeRTOS on Hercules Devices
  3.   Trademarks
  4. 1FreeRTOS Source Files
  5. 2FreeRTOS Support in HALCoGen
  6. 3MPU Settings as an Add-on for Safety Use Cases
    1. 3.1 MPU Wrapper Functions
    2. 3.2 MPU Regions for Tasks
  7. 4Porting FREERTOS on a Different Part Number
  8. 5Revision History

MPU Regions for Tasks

The FreeRTOS task driver provides support to have n number of memory regions assigned to each task. The memory regions and its access rights may vary, depending on the tasks.

In a FreeRTOS environment, the MPU regions can be categorized into task-specific regions and common regions. Task-specific regions are configured every time a task switch occurs. The common regions are configured at the time the scheduler is initialized.

The first four regions and the last region (regions 0-3 and n-1) are configured when the scheduler is started and are common for all the tasks. This includes the flash, RAM, and peripherals memories. The other regions are task-specific, and can be configured during the task creation. There is a dedicated MPU region for the task stack.

Table 3-1 lists the device families with the number of MPU regions, and how they are split into common and task-specific regions.

Table 3-1 Device Families
Device FamilyNo. of MPU RegionsCommon RegionsTask-Specific Regions
TMS570LS31x RM48x
TMS570LS12x RM46x
12

Region 0: Unprivileged flash region

Region 1: Privileged flash region

Region 2: Privileged RAM region

Region 3: Peripherals region

Region 11: Privileged system region

Region 4: Task stack

Regions 5-10: User-defined

TMS570LS04x RM42x8

Region 0: Unprivileged flash region

Region 1: Privileged flash region

Region 2: Privileged RAM region

Region 3: Peripherals region

Region 7: Privileged system region

Region 4: Task stack

Regions 5,6: User-defined

TMS570LC43x RM57x16

Region 0: Unprivileged flash region

Region 1: Privileged flash region

Region 2: Privileged RAM region

Region 3: Peripherals region

Region 15: Privileged system region

The number of task-configurable regions can be changed in the HALCoGen GUI. Default = 3

Region 11: Task stack

Regions 12-14: User-defined

The remaining regions can be configured in the HALCoGen GUI, and are common for all tasks.

Note:

Privileged flash and RAM regions include the privileged code and data section used by the kernel.

All the MPU configurations done through the HALCoGen GUI are reset when the scheduler is initialized. With TMS570LC43x and RM57x devices, there is an option to set the number of regions used by the FreeRTOS. The regions not used by FreeRTOS can be configured through the HALCoGen GUI. These are not reset by the FreeRTOS code.

To modify the default MPU regions set by FreeRTOS, modify the prvSetupDefaultMPU function available on the os_port.c file.

A task can be created using two FreeRTOS APIs:

  • xTaskCreate — This disables all user-defined task-specific regions, and enables access to the entire RAM region as part of the task stack region. The task created using this API is called a non-restricted task, as this has access to the entire RAM region.
  • xTaskCreateRestricted — This lets the user define the regions they need access to. The task stack region is set with the actual stack size. The task created using this API is called a restricted task, as this does not have access to any RAM region other than its own stack (unless explicitly mentioned).

For more details on how to create restricted and non-restricted tasks, see the HALCoGen examples.