2013-11-15 07:35 AM
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-paypal2013-11-15 11:02 AM
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.2013-11-15 11:40 AM
2013-11-17 04:55 PM
Enable the SYSCFG clock, and try not to break the configuration of other pins, like the JTAG/SWD ones (PA13,14)