2021-05-08 10:13 AM
Hi, I'm trying to execute an interrupt with the pin PCO with stm32f303re Nucleo board, but the interrupt routine never executes, actually, it just stops the program. this is my configuration code for the interrupt:
//set gpioc 0 as interrupt
__disable_irq();
SYSCFG->EXTICR[0] |= 0x2;
EXTI->IMR |= (1 << 0);
EXTI->RTSR &= ~(1 << 0); //configure pin 0 as interrupt, fall edge
EXTI->FTSR |= (1 << 0);
NVIC_EnableIRQ(EXTI0_IRQn);
NVIC_SetPriority(EXTI0_IRQn, 0);
__enable_irq();
and this is my Interrupt routine:
void EXTI0_IRQHandler(void) {
counter2++;
EXTI->PR |= EXTI_PR_PR0;
}
and in the debug view i can see that the processor triggers the interrupt, but it just stuck the program and the interrupt is never executed:
before pressing the button connected to PC0:
after pressing the button:
Thanks for any help.
2021-05-09 07:42 AM
Ok, I was experimenting because I literally copied and paste the code, but it seems the problem is that the version i was running in keil uvision is C++ and in the CUBE IDE was C, so I changed the C++ type file in keil to C and it works perfectly. Any idea why?
2021-05-09 07:52 AM
C++ uses name mangling
use form
extern "C" void EXTI0_IRQHandler(void) {
...
}
2021-05-09 08:03 AM
oh wow, I didn't know that, thank you very much!