AnsweredAssumed Answered

Interrupt service routine and C++

Question asked by Jedix on Nov 18, 2012
Latest reply on Nov 23, 2012 by Jedix

 Hey everyone,

 

I'm working on the STM32F4DISCOVERY with CoIDE 1.6.0 in C++. I have an interrupt on TIMER4 overflow, and so I put the interrupt service routine (void TIM4_IRQHandler(void) {}) in the main.cpp. But if I just do that it doesn't work as I end up in the Default_Handler. I figure out it was like the routine was not found in execution. So I put extern "C" around my routine

#ifdef __cplusplus
extern "C" {
#endif
void TIM4_IRQHandler(void) {
...
}
#ifdef __cplusplus
}
#endif

And it worked. But now I can't use C++ code in this routine whereas I'd like to get the instance of a singleton in it. I'm stuck, would you have some solution or workaround ? Thank you very much :)

Outcomes