2020-11-30 06:43 AM
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
2020-11-30 07:22 AM
Did you choose appropriate task priorities ?
2020-11-30 11:37 PM
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
2020-12-01 01:16 AM
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 ?
2020-12-01 01:27 AM
Hi hs2,
Thanks for your suggestions. I will try and update here.
Regards,
Asish Banerjee
2020-12-01 01:31 AM
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,