AnsweredAssumed Answered

STM32F103 EXTI not firing?

Question asked by blesener.daniel on Apr 20, 2015
Latest reply on Apr 20, 2015 by Clive One
Written this code many times. No clue why it is not working. See any obvious errors?

//CODE FOR INIT. Note that APB2 clocks are initialized for ports

  GPIO_InitTypeDef GPIO_EXTI0;
 
  GPIO_EXTI0.GPIO_Pin = GPIO_Pin_7;
  GPIO_EXTI0.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOA, &GPIO_EXTI0);

 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

 

  GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource7);

  EXTI_InitTypeDef   EXTI_InitStructure;
  EXTI_InitStructure.EXTI_Line = EXTI_Line7;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);

  NVIC_InitTypeDef NVIC_InitStructure;
 
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

 
  GPIO_InitTypeDef GPIO_InitStructure4;
  GPIO_InitStructure4.GPIO_Pin = GPIO_Pin_4;
  GPIO_InitStructure4.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure4.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOC, &GPIO_InitStructure4);
  GPIO_ResetBits(GPIOC, GPIO_Pin_4);                            //All LED control is made with 3.3V-->220R-->MCU, so pull down to turn on.


//CODE FOR INTERUPT 

void EXTI9_5_IRQHandler(void)
{
  if(EXTI_GetITStatus(EXTI_Line7) != RESET)
  {
    /* Clear the  EXTI line 0 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line7);
        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7))
            {
            lsb = GPIO_ReadInputData(GPIOG);
            msb = GPIO_ReadInputData(GPIOF) & 0b0000000001111111;
            msb = msb<<16;
            final_val = lsb | msb;
            clear_shift_reg();
           
            }
  }
 
}

Thanks!

Outcomes