cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX_Task() not called with project generated by designer.

ACapo.1
Senior

The generated code:

/* Definitions for TouchGFXTask */
osThreadId_t TouchGFXTaskHandle;
const osThreadAttr_t TouchGFXTask_attributes = {
  .name = "TouchGFXTask",
  .stack_size = 3048 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};

and

TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);

With this code TouchGFX_Task() is never called.

So as a test I duplicated everything:

/* Definitions for TouchGFXTask */
osThreadId_t TouchGFXTaskHandle;
const osThreadAttr_t TouchGFXTask_attributes = {
  .name = "TouchGFXTask",
  .stack_size = 3048 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
 
osThreadId_t TouchGFXTaskHandle2;
const osThreadAttr_t TouchGFXTask_attributes2 = {
  .name = "TouchGFXTask2",
  .stack_size = 3048 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};

and

/* Create the thread(s) */
  /* creation of TouchGFXTask */
  TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);
 
  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  TouchGFXTaskHandle2 = osThreadNew(TouchGFX_Task2, NULL, &TouchGFXTask_attributes2);
 
  /* USER CODE END RTOS_THREADS */

Now TouchGFX_Task() is called but TouchGFX_Task2() is not called!

Adding more threads has no difference, they are never called but TouchGFX_Task() is.

Has anyone any idea what might be going on here?

Thanks

Andy

3 REPLIES 3
Yoann KLEIN
ST Employee

Hello @ACapo.1​,

Not sure that it is the solution, but if you are using FreeRTOS, did you think about creating a task in CubeMX, like it is written in the documentation ?

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX
ACapo.1
Senior

Hi, Thanks for the reply.

The TouchGFX_TASK is already defined there, so I added two more

0693W00000aJqEvQAK.pngWith this setup StartTask02() is called, the other two are not called!

The changes made are basically what I was doing manually but with a different outcome!

diff --git a/CM7/Core/Src/main.c b/CM7/Core/Src/main.c
index ea728a4..2406fbd 100644
--- a/CM7/Core/Src/main.c
+++ b/CM7/Core/Src/main.c
@@ -71,6 +71,20 @@ const osThreadAttr_t TouchGFXTask_attributes = {
   .stack_size = 3048 * 4,
   .priority = (osPriority_t) osPriorityNormal,
 };
+/* Definitions for myTask02 */
+osThreadId_t myTask02Handle;
+const osThreadAttr_t myTask02_attributes = {
+  .name = "myTask02",
+  .stack_size = 3048 * 4,
+  .priority = (osPriority_t) osPriorityNormal,
+};
+/* Definitions for myTask03 */
+osThreadId_t myTask03Handle;
+const osThreadAttr_t myTask03_attributes = {
+  .name = "myTask03",
+  .stack_size = 3048 * 4,
+  .priority = (osPriority_t) osPriorityNormal,
+};
 /* USER CODE BEGIN PV */
 OTM8009A_Object_t OTM8009AObj;
 OTM8009A_IO_t IOCtx;
@@ -87,6 +101,8 @@ static void MX_DMA2D_Init(void);
 static void MX_DSIHOST_DSI_Init(void);
 static void MX_LTDC_Init(void);
 void TouchGFX_Task(void *argument);
+void StartTask02(void *argument);
+void StartTask03(void *argument);
 
 /* USER CODE BEGIN PFP */
 
@@ -212,6 +228,12 @@ Error_Handler();
   /* creation of TouchGFXTask */
   TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);
 
+  /* creation of myTask02 */
+  myTask02Handle = osThreadNew(StartTask02, NULL, &myTask02_attributes);
+
+  /* creation of myTask03 */
+  myTask03Handle = osThreadNew(StartTask03, NULL, &myTask03_attributes);
+
   /* USER CODE BEGIN RTOS_THREADS */
   /* add threads, ... */
   /* USER CODE END RTOS_THREADS */
@@ -806,6 +828,42 @@ __weak void TouchGFX_Task(void *argument)
   /* USER CODE END 5 */
 }
 
+/* USER CODE BEGIN Header_StartTask02 */
+/**
+* @brief Function implementing the myTask02 thread.
+* @param argument: Not used
+* @retval None
+*/
+/* USER CODE END Header_StartTask02 */
+__weak void StartTask02(void *argument)
+{
+  /* USER CODE BEGIN StartTask02 */
+  /* Infinite loop */
+  for(;;)
+  {
+    osDelay(1);
+  }
+  /* USER CODE END StartTask02 */
+}
+
+/* USER CODE BEGIN Header_StartTask03 */
+/**
+* @brief Function implementing the myTask03 thread.
+* @param argument: Not used
+* @retval None
+*/
+/* USER CODE END Header_StartTask03 */
+__weak void StartTask03(void *argument)
+{
+  /* USER CODE BEGIN StartTask03 */
+  /* Infinite loop */
+  for(;;)
+  {
+    osDelay(1);
+  }
+  /* USER CODE END StartTask03 */
+}
+
 /* MPU Configuration */
 
 void MPU_Config(void)

ACapo.1
Senior

Ok I think I have worked it out.

That TouchGFX_Task code should not be in main.c, I have no idea why it was generated there.

The actual TouchGFX_Task() is in app_touchgfx.c

Still a little strange that only one of the other tasks is being called though!