Skip to main content
madhavi U
Associate II
July 22, 2023
Solved

tim2 interrupt activate causes infinite loop in stm32

  • July 22, 2023
  • 2 replies
  • 1635 views

I have generated C project with Tim2 interrupt configuration from CubeMX and converted into C++ project. when the project is in C timer2 is working. but when I changed it to C++ project, after interrupt enable function execution it stuck at Infinite Loop statement. why?can anyone help me out?

after below mentioned statement execution,it's going to infinite loop statement.

if (HAL_TIM_Base_Start_IT(&htim2) != HAL_OK)
{
Error_Handler();
}

 .section .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
b Infinite_Loop
.size Default_Handler, .-Default_Handler

 

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

The key phrase is C++ name mangling. Every interrupt service routine must be C, not C++. So either place it in a .c file or add extern "C" attribute to its definition.

2 replies

gbm
gbmBest answer
Super User
July 22, 2023

The key phrase is C++ name mangling. Every interrupt service routine must be C, not C++. So either place it in a .c file or add extern "C" attribute to its definition.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
madhavi U
madhavi UAuthor
Associate II
July 22, 2023

yah, after adding extern "C"  attribute into ISR definition it's working. thanks 8)