nucleo-f401re button interrupt keep getting into the irq handler
The source pin for EXTI13 must be selected. It can be any of PA13, PB13, PC13 etc, and the SYSCFG-&gt;EXTICR registers tell the system which one to use.

RCC-&gt;APB2ENR |= RCC_APB2ENR_SYSCFGEN;
RCC-&gt;APB2ENR; // see "Delay after an RCC peripheral clock enabling" in the errata sheet
SYSCFG-&gt;EXTICR[3] |= SYSCFG_EXTICR4_EXTI13_PC; // EXTICR4 in the Reference Manual correspond to EXTICR[3]!


Without setting it defaults to PA13 (value 0), which is used as the SWDIO line from the onboard debugger. Any activity by the debugger triggers the interrupt.

By the way, don't forget to enable GPIOC in the clock controller. Same errata as above applies, you might want to interleave it with the code above to have the necessary delays without extra code.

RCC-&gt;APB2ENR |= RCC_APB2ENR_SYSCFGEN;
RCC-&gt;AHB1ENR |= RCC_AHB1ENR_GPIOCEN;
SYSCFG-&gt;EXTICR[3] |= SYSCFG_EXTICR4_EXTI13_PC;