Skip to main content
Kmax18
Senior II
August 9, 2023
Solved

STM32F103RB program hangs after calling HAL_TIM_Base_Start_IT()

  • August 9, 2023
  • 2 replies
  • 2886 views

Hello, I am using the NUCLE-F103RB and the STM32CubeIDE for developing and testing code. After my latest code change the program does not return form the below call of HAL_TIM_Base_Start_IT(&htim3).

"TEST1" is printed to the terminal, but "TEST2" is not.

Not sure if this is related, but during uploading to the NUCLEO the cursor stops is in the file sysmem.c at

 

void *_sbrk(ptrdiff_t incr)

 

This is the code where the program 'hangs'...

 

sprintf(msgString, "TEST1\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msgString, strlen(msgString) , 0xFF);
/* Start the TIM Base generation in interrupt mode */
if (HAL_TIM_Base_Start_IT(&htim3) != HAL_OK) {
 Error_Handler();
}
sprintf(msgString, "TEST2\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msgString, strlen(msgString) , 0xFF);

 

Can this issue be related to memory management? Thank you!

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

Your timer triggers interrupts so fast that the CPU can't make any progress. Or your interrupt handler is very slow or never returns.

Slow down the timer, check your interrupt handler.

Run the debugger and hit pause when it's stuck to find out where the CPU is at.

2 replies

RhSilicon
Lead
August 9, 2023

Starts the interrupt, but is the interrupt being handled?

RhSilicon
Lead
August 9, 2023

I don't know if it can help in your case, but I found these videos about advanced debugging:

STM32CubeIDE Advanced Debug Features
https://youtube.com/playlist?list=PLnMKNibPkDnEDEsV7IBXNvg7oNn3MfRd6

TDK
TDKBest answer
Super User
August 9, 2023

Your timer triggers interrupts so fast that the CPU can't make any progress. Or your interrupt handler is very slow or never returns.

Slow down the timer, check your interrupt handler.

Run the debugger and hit pause when it's stuck to find out where the CPU is at.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Kmax18
Kmax18Author
Senior II
August 10, 2023

Thank you, TDK! You are correct: the callback function was too busy. I fixed it.