Restricted task calling a function caused Memory Exception

Hello All,

Please pardon me if this query sounds silly.

I have configured my project to use FreeRTOS with MPU and created a restricted task which has got a simple xTaskDelayUntil function in it. This works fine without any issues.

But as soon as I call a dummy function it gives memory exception.

My dummy function is simply incrementing a counter.

static void dummyFunction()
static uint32_t callCounter = 0U;

And my task function looks like this:

static void main_1000ms_task( void *pvParameters)
TickType_t xFrequency;
xFrequency = 1000;
TickType_t xLastWakeTime = xTaskGetTickCount();

    (void)xTaskDelayUntil( &xLastWakeTime, xFrequency );


Looking at the assemble code for dummyFunction, it seems that the memory exception occurs when CPU is trying to access Stack memory of dummyFunction.

Can you please tell me if my understanding is correct and how to get round this issue.


Restricted tasks can only modify/access the memory that it has been given privilege to access. By default, they are allowed to write to their stack memory. Static variables are NOT put on the stack.

You need to do something to put that static variable into a segment that the task is given privilege to modify.

Also, you can take a look at this example for how to grant a task access to certain memory area - FreeRTOS/mpu_demo.c at main · FreeRTOS/FreeRTOS · GitHub

Many thanks @aggarg and @richard-damon

I understand the issue and was able to resolve it with your assistance.