cancel
Showing results for 
Search instead for 
Did you mean: 

stmf4 external interrupt

sen
Associate II
Posted on November 15, 2013 at 16:35

I have a rather simple problem. Just trying to run the external interrupt on pin PA0 on stmf4-discovery without the library functions. It ran correctly on simulation trial using stm32f103 device. But I'm missing out something in implementing this on stmf4-disc hardware. Can someone point out the mistake? Here is the piece of my code:

&sharpinclude <stdio.h>

&sharpinclude <stm32f4xx.h>

&sharpinclude ''LED.h''

extern void LED_Init (void);

extern void LED_On (unsigned int num);

extern void LED_Off (unsigned int num);

void button_init()

{

    RCC->AHB1ENR     |=  ((1UL << 0) );                 /* Enable GPIOA clock              */

    GPIOA->MODER = 0x00000000;

 GPIOA->PUPDR = 0x55555555;

}

void wait (void)  {

  int  d;

  for (d = 0; d < 200000; d++);             /* only to delay for LED flashes */

}

int main()

{

  SystemCoreClockUpdate();           /* Get Core Clock Frequency   */

    if (SysTick_Config(SystemCoreClock / 1000)) { /* SysTick 1 msec interrupts  */

      while (1);                               

    }

  LED_Init();

  button_init(); //BUtton on PA0

  EXTI->IMR |= (1UL<<0); // Enable not maskable interrupt on BIT1 

  EXTI->RTSR |= (1UL<<0); // Rising Edge

  //SYSCFG->EXTICR[0] &= ~BIT1; //  0000 for interrupt for PA[0]

  NVIC_EnableIRQ(6); 

  while(1)

{

  }

}

void EXTI0_IRQHandler(void)

  if(EXTI->PR & 1UL)

  {

    EXTI->PR |= 1; // Clear with Setting to BIT1

    LED_On(3);

  }  

}

With Thanks,

Tapabrata

#i-accept-paypal
3 REPLIES 3
Posted on November 15, 2013 at 20:02

But I'm missing out something in implementing this on stmf4-disc hardware.

What's that condition where you keep doing things a particular way despite it causing pain every time?

I see at least one problem here that's definitely preventing it from working.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sen
Associate II
Posted on November 15, 2013 at 20:40

The pain is that it's bit embarrassing to none but myself that something that can be done so easily with the wonderful library functions available causing trouble when tried with the other way available. I may not need to look at the registers with having the library available, but it's definitely  not worth forgetting the root, afterall it is rather the economical way of programing in terms of memory utilisation I guess. So this is the reason for bearing the brunt.  

Posted on November 18, 2013 at 01:55

Enable the SYSCFG clock, and try not to break the configuration of other pins, like the JTAG/SWD ones (PA13,14)

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