AnsweredAssumed Answered

STM32F4 External button not working !

Question asked by ghanmy.montassar on Jul 20, 2015
Latest reply on Jul 21, 2015 by ghanmy.montassar
I'm trying to interface a push button to my stm32F4 discovery via PA1 , this is the code I got : 

void EXTI1_IRQHandler(void)
  if(EXTI_GetITStatus(EXTI_Line1) != RESET)

    // Code goes here.

void initButton(void)
  GPIO_InitTypeDef GPIO_InitStructure;
  EXTI_InitTypeDef EXTI_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;

  /* Enable GPIOA clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);

  EXTI_InitStructure.EXTI_Line = EXTI_Line1;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;


And the circuit I'm using :

When I clicked nothing happened :/
What's even weirder when I unplugged the jumper that connect this to PA1 the function suddenly worked and the LED started blinking !!! 
I tried again and seems that connecting the jumper alone to the pin PA1 triggers the function !!! like it's just a wire, why would this happen ?

Can anyone tell me what I'm doing wrong ?? Thank you.