Question
stmf4 external interrupt
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