Skip to main content
Associate III
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!

 

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

Andrew Neil
Super User
May 8, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Technical Moderator
May 14, 2025

@JonConesa 

Any update concerning this issue?

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
JonConesaAuthorBest answer
Associate III
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.