Skip to main content
HPham.1590
Associate III
August 14, 2020
Solved

FreeRTOS is not running task

  • August 14, 2020
  • 4 replies
  • 4076 views

Hello, I'm using FreeRTOS on STM32F746NG.

I have created 4 task which run with the same priority.

But when I run my code,Only StartDefaultTask running, others aren't.

In debug mode, when I clicked Resume(F8), the pointer always jump to start of StartDefaultTask function.

My functions are working correctly in another project.

Anyone can help my fix this bug?

Many thanks,

Hieu

Here is my task define:

osThreadId defaultTaskHandHandle;
osThreadId MQTTTaskHandHandle;
osThreadId PubTaskHandHandle;
osThreadId UpdateTaskHandle;
void StartDefaultTask(void const * argument);
//void StartDefaultTask(void * argument);
/* USER CODE BEGIN PFP */
void MQTTTask(void *client);
void PubTask(void *argument);
void SyncTask(void *argument);
 osThreadDef(defaultTaskHand, StartDefaultTask, osPriorityNormal, 0, 4096);
 defaultTaskHandHandle = osThreadCreate(osThread(defaultTaskHand), NULL);
 osThreadDef(MQTTThread, MQTTTask, osPriorityNormal, 0, 1024);
 MQTTTaskHandHandle = osThreadCreate(osThread(MQTTThread), client);
 osThreadDef(PubThread, PubTask, osPriorityNormal, 0, 512);
 PubTaskHandHandle = osThreadCreate(osThread(PubThread), client);
 osThreadDef(UpdateThread, SyncTask, osPriorityNormal, 0, 256);
 UpdateTaskHandle = osThreadCreate(osThread(UpdateThread), client);
 /* USER CODE BEGIN RTOS_THREADS */

Here is my StartDefaultTask, this task running with TouchGFX

void StartDefaultTask(void const * argument)
{
 /* USER CODE BEGIN 5 */
//	mqtt_do_connect(argument);
 MX_TouchGFX_Process();
 /* Infinite loop */
 for(;;)
 {
 
 osDelay(1);
 }
 /* USER CODE END 5 */
}

    This topic has been closed for replies.
    Best answer by KnarfB

    and when you set a breakpoint in another task?

    4 replies

    KnarfB
    KnarfBBest answer
    Super User
    August 14, 2020

    and when you set a breakpoint in another task?

    HPham.1590
    Associate III
    August 17, 2020

    many thanks KnarfB, a unexpected breakpoint was set in my code but it's invisible in my debug mode. I dont know why but when I removed it, my program worked.

    Haithem Rahmani
    ST Employee
    August 14, 2020

    Hi,

    Are you sure that the threads were correctly created? could you check that the thread_id handles are not "NULL",

    if it is the case then try to increase the FreeRTOS heap in the FreeRTOSConfig.h file.

    regards

    Haithem.

    HPham.1590
    Associate III
    August 17, 2020

    many thanks KnarfB, a unexpected breakpoint was set in my code but it's invisible in my debug mode. I dont know why but when I removed it, my program worked.