Skip to main content
Explorer
November 30, 2020
Question

FreeRTOS task switching issue.

  • November 30, 2020
  • 4 replies
  • 2102 views

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

    This topic has been closed for replies.

    4 replies

    Visitor II
    November 30, 2020

    Did you choose appropriate task priorities ?

    ABane.1Author
    Explorer
    December 1, 2020

    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

    Visitor II
    December 1, 2020

    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,

    Visitor II
    December 1, 2020

    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.1Author
    Explorer
    December 1, 2020

    Hi hs2,

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

    Regards,

    Asish Banerjee