cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS task switching issue.

ABane.1
Associate II

Hello,

I am facing problem with task switching in FreeRTOS. I am using my custom board with STM32L476RC running at 80 MHz clock. Using STM32CubeIDE and configured project using CubeMX. I am using 3 tasks. Task 1 has some functions which uses osDelay and while loop (Used for GSM module operation). Task 2 used for TFT display update on every one second. Task 3 is used for data acquisition. My problem is when Task 1 is in odDelay or in while loop, other tasks are not functioning hence my TFT is not always updating every one second. Is there any way to configure FreeRTOS to switch tasks even one task is busy? Kindly help me to overcome this problem.

Regards,

Asish Banerjee

5 REPLIES 5
hs2
Senior

Did you choose appropriate task priorities ?

ABane.1
Associate II

Hi hs2,

Bellow is the task priorities I have set.

Task 1 : osPriorityNormal

Task 2 : osPriorityBellowNormal

Task 3 : osPriorityBellowNormal1

USE_PREEMPTION   is Enabled

Is anything wrong i configured here?

Regards

Asish Banerjee

hs2
Senior

If task1 has the highest prio, it runs as long as it's busy resp. until it's blocking on something or sleeping in osDelay (vTaskDelay internally).

So in your case during osDelay task2/3 are running if they in turn are not waiting for something (e.g. a semaphore) or sleeping themselves.

Did you verify which task is running during osDelay of task1 ?

Did you try an other prio order e.g. give task2 the highest prio if you want that the display is updated in any case ?

ABane.1
Associate II

Hi hs2,

Thanks for your suggestions. I will try and update here.

Regards,

Asish Banerjee

If Task1 is in some while loop as you said or it is not waiting for semaphore or data from queue (task does not go into blocked state) the task with lower priority will not preempt current running task and will not execute. It will execute when running task goes into blocked state. Try to change your priorities to allow task1 preemption.

Regards,