Skip to main content
Graduate
May 8, 2025
Solved

Issue with HAL_Delay() and ThreadX

  • May 8, 2025
  • 3 replies
  • 638 views

Hello everyone,

I am encountering an issue with the HAL_Delay() function and ThreadX in my project. Before initializing ThreadX, HAL_Delay() works as expected. Specifically, the callback function:

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
 /* USER CODE BEGIN Callback 0 */

 /* USER CODE END Callback 0 */
 if (htim->Instance == TIM6)
 {
 HAL_IncTick();
 }
 /* USER CODE BEGIN Callback 1 */
 WR_TIMER_process();
 /* USER CODE END Callback 1 */
}

is triggered correctly, and the uwTick variable increments as intended.

I am using Timer6 for the system ticks on a custom PCB with an STM32H743BIT MCU. However, after calling the MX_ThreadX_Init() function, the uwTick variable stops updating, and the HAL_TIM_PeriodElapsedCallback is no longer triggered.

 

Here is my setup:

  • MCU: STM32H743BIT

  • Compiler: arm-none-eabi-gcc (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 14.2.1 20241119

  • CubeMX Version: 6.14.0

  • ThreadX Version: 6.4.0
  • Debugger: J-Link 8.32

  • Ozone Version: 3.38g

 

It seems like the initialization of ThreadX might be interfering with the callback mechanism. Has anyone experienced a similar issue, or does anyone know what could cause the callback to stop triggering after initializing ThreadX?

 

Thank you for your help!

 

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

    Hi,

    The issue occurs when calling HAL_Delay() within the function:

    UINT App_ThreadX_Init(VOID *memory_ptr).

    I removed the delays that were placed inside this function and moved them to the thread, where they worked correctly.

    I understand that certain HAL functions cannot be called until the ThreadX initialization is fully completed.

    Best regards,

    Jon.

    3 replies

    Technical Moderator
    May 14, 2025

    @JonConesa 

    Any update concerning this issue?

    JonConesaAuthorAnswer
    Graduate
    May 20, 2025

    Hi,

    The issue occurs when calling HAL_Delay() within the function:

    UINT App_ThreadX_Init(VOID *memory_ptr).

    I removed the delays that were placed inside this function and moved them to the thread, where they worked correctly.

    I understand that certain HAL functions cannot be called until the ThreadX initialization is fully completed.

    Best regards,

    Jon.