Skip to main content
JMart.13
Associate III
May 8, 2021
Question

External interrupt Handler does not execute

  • May 8, 2021
  • 6 replies
  • 2296 views

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:

0693W00000ANkrMQAT.pngafter pressing the button:

0693W00000ANkrgQAD.png 

Thanks for any help.

This topic has been closed for replies.

6 replies

waclawek.jan
Super User
May 8, 2021

If you stop execution in debugger, what do you see, where is the PC, how does the ISR look like?

JW

JMart.13
JMart.13Author
Associate III
May 8, 2021

when you refer to PC as the port? and which one is ISR? I know that peripherals like i2c and usart have ISR, but EXTI does not have one.

waclawek.jan
Super User
May 8, 2021

No, Program Counter, i.e. which is the currently executed instruction, is it in the ISR?

ISR is the Interrupt Service Routine Ii.e. here EXTI0_IRQHandler()); I am interested in how it looks in the disassembly view.

JW

JMart.13
JMart.13Author
Associate III
May 8, 2021

Honestly, this is what i have seen, the compiler does not create asm code for the ISR, i don't know why, so i can't see it in disassembly view. I don't know if this helps

waclawek.jan
Super User
May 8, 2021

> the compiler does not create asm code for the ISR

That's problem.

What toolchain are you using?

Consult the toolchain's manual for proper way to use ISRs, study available examples. Some toolchains require a special way to tag ISRs, to prevent them being optimized out.

Check if the ISR's name matches that in the vector table (case sensiive), which is usualy located in the startup file.

JW

JMart.13
JMart.13Author
Associate III
May 8, 2021

I'm using st-link for the debug and programming of the microcontroller, Keil uVision for my IDE, and the name of the handler in the startup file is "EXTI0_IRQHandler" so is correctly spelled.

waclawek.jan
Super User
May 8, 2021

Try to look at the available examples, e.g. in Cube.

JW

JMart.13
JMart.13Author
Associate III
May 8, 2021

Is interesting, in CUBE IDE, it works perfectly :\

waclawek.jan
Super User
May 9, 2021

As opposed to what?

Try to find the differences by comparison.

JW

JMart.13
JMart.13Author
Associate III
May 9, 2021

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?

Tesla DeLorean
Guru
May 9, 2021

C++ uses name mangling

use form

extern "C" void EXTI0_IRQHandler(void) {

...

}

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..