cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with HAL_Delay() and ThreadX

JonConesa
Associate III

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
JonConesa
Associate III

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.

View solution in original post

3 REPLIES 3
Andrew Neil
Super User

https://community.st.com/t5/stm32-mcus-embedded-software/f767-freertos-lwip-gt-hal-delay-fails/m-p/799506/highlight/true#M63016

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.
Saket_Om
ST Employee

@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
JonConesa
Associate III

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.