cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DISCOVERY wrong EXTI port

ppkettu
Associate II
Posted on March 04, 2014 at 23:10

I'm trying to do a pin interrupt (EXTI).   My code:  // IRQ handler for EXTI0

void

EXTI0_IRQHandler (

void

) {

EXTI->PR = 1UL << 0;

buttonPress = 1;

}

int

main (

void

) {

// some system stuff here ...

GPIO_PortClock (GPIOD,

true

);

GPIO_PinConfigure(GPIOD, 0, GPIO_MODE_INPUT, GPIO_OUTPUT_PUSH_PULL,

GPIO_OUTPUT_SPEED_25MHz, GPIO_PULL_UP);

// EXTI line 0

EXTI_ConfigureLine(0, EXTI_MODE_INTERRUPT, EXTI_TRIGGER_FALLING);

// Port D

EXTI_ConfigurePin(0, EXTI_PIN_PD);

NVIC_EnableIRQ(EXTI0_IRQn);

// ... etc

}

  The problem is, whatever port I have on the EXTI_ConfigurePin(), the interruption goes to port A. So the PA0 always triggers the handler, not PD0 or whatever I'm trying to use.   The functions I'm using are KEIL. I suppose they are working right, so did I forget some step, or what could it be causing the problem? 

#exti #discovery #stm32f4

3 REPLIES 3
Posted on March 05, 2014 at 04:20

Not familiar with the library you're using, review the EXTI example projects in ST's library

I'd hazard you need to enable the SYSCFG clock if you want to change the EXTI pin routing. It only supports one pin per line.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ppkettu
Associate II
Posted on March 05, 2014 at 11:12

Yeah, the SYSCFG clock, that did it! Thanks, Clive1!

In Keil uVision, there is a file named RTE_Device.h. If you open it, you'll see a configuration wizard tab under the text editor. From there you just open ''EXTI controller'' and enable it. Then just call EXTI_Setup() in your code, and that enables that SYSCFG clock.

In fact, that wizard can also do the EXTI_ConfigureLine and EXTI_ConfigurePin stuff for you. But then you can't have EXTI0_IRQHandler() in your code, but EXTI0_Event().

Quite handy, but if I'll use this, I guess no-one can read my listings...

By ST's library, you mean STM32Cube firmware, right? I found an EXTI example there.

Posted on March 06, 2014 at 14:32

No, the original firmware library they deprecated the other week, but most everyone else is still using it.

http://www.st.com/web/en/catalog/tools/PF257901

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