Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training

[FreeRTOS-MPU Specific]

task. h
void vTaskAllocateMPURegions(
               TaskHandle_t xTaskToModify,
               const MemoryRegion_t * const xRegions );

Memory regions are assigned to a restricted task when the task is created using a call to xTaskCreateRestricted(). The regions can then be modified or redefined at run time using vTaskAllocateMPURegions().

vTaskAllocateMPURegions() is intended for use with FreeRTOS-MPU, the demo applications for which contain an example of vTaskAllocateMPURegions() being used.

xTask The handle of the task being updated.
xRegions A pointer to an array of MemoryRegion_t structures, each of which contains a single new memory region definitions. The array should be dimensioned using the constant portNUM_CONFIGURABLE_REGIONS, which on the ARM Cortex-M3 is set to 3.

MemoryRegion_t is defined in task.h as:

typedef struct xMEMORY_REGION
    void *pvBaseAddress;
    unsigned long ulLengthInBytes;
    unsigned long ulParameters;
} MemoryRegion_t;

The pvBaseAddress and ulLengthInBytes members are self explanatory as the start of the memory region and the length of the memory region respectively. It is important to note that MPU regions must meet a number of constraints - in particular, the size and alignment of each region must both be equal to the same power of two value.

ulParameters defines how the task is permitted to access the memory region and can take the bitwise OR of the following values:


Example usage (please refer to the FreeRTOS-MPU demo applications for a much more complete and comprehensive example):

/* Define an array that the task will both read from and write to. Make sure the size and alignment are appropriate for an MPU region (note this uses GCC syntax). */ static unsigned char ucOneKByte[ 1024 ] __attribute__((align( 1024 ))); /* Define an array of MemoryRegion_t structures that configures an MPU region allowing read/write access for 1024 bytes starting at the beginning of the ucOneKByte array. The other two of the maximum 3 definable regions are unused so set to zero. */ static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] = { /* Base address Length Parameters */ { ucOneKByte, 1024, portMPU_REGION_READ_WRITE }, { 0, 0, 0 }, { 0, 0, 0 } }; void vATask( void *pvParameters ) { /* This task was created such that it has access to certain regions of memory as defined by the MPU configuration. At some point it is desired that these MPU regions are replaced with that defined in the xAltRegions const struct above. Use a call to vTaskAllocateMPURegions() for this purpose. NULL is used as the task handle to indicate that this function should modify the MPU regions of the calling task. */ vTaskAllocateMPURegions( NULL, xAltRegions ); /* Now the task can continue its function, but from this point on can only access its stack and the ucOneKByte array (unless any other statically defined or shared regions have been declared elsewhere). */ }

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists