AnsweredAssumed Answered

stmf4 external interrupt

Question asked by sen.tapabrata on Nov 15, 2013
Latest reply on Nov 18, 2013 by Clive One
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:

#include <stdio.h>
#include <stm32f4xx.h>
#include "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

Outcomes