Search code examples
cstm32keil

STM32F4 interrupt


I am trying to do very simple interrupt code in STM32F401RE where I press the button and LED2 should turn on based on external interrupt triggered by the button.

I am using the user button(blue button) in nucleo board F401 which corresponds to PC13 according to the board datasheet pinout. I tried different options but LED2 is still off, here is the code i am using:


int main(void)
{
 sysconfig();
 Interrupt_config();    
 while(1)
 {
    if(flag)
     {
      GPIOA->ODR |= (1<<5);
     }
 }

 }

I used polling method (without interrupt) and the LED2 turns on fine when the button is pressed using only LED_initialize(); Button_init();


Solution

  • Haven't checked your IRQ setup code, but the handler you need for PC13 is EXTI15_10_IRQHandler.

    Edit:

    Another issue: EXTICR is 4 words long. This is incorrect: SYSCFG->EXTICR[4] |=(1<<5);.