AnsweredAssumed Answered

stm32f103 button interrupt not working

Question asked by David.Don on Mar 23, 2017
Latest reply on Apr 28, 2017 by jones.david.016

Hi All,

 

I am working on button press interrupt on stm32f103 . I am not able to get it into work. I am not at all receiving any interrupt when the button which is connected to PORT B 12 13 14 is pressed

 

Below is my code snippet. Please Help

 

 

void init_exti()
{

 

    EXTI_InitTypeDef   EXTI_InitStructure;
    GPIO_InitTypeDef   GPIO_InitStructure;
    NVIC_InitTypeDef   NVIC_InitStructure;

 

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
      /* Configure PA.00 pin as input floating */
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12
      | GPIO_Pin_13 |GPIO_Pin_14;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//input pull up
      GPIO_Init(GPIOC, &GPIO_InitStructure);
       /* Enable AFIO clock */
      RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
        /* Connect EXTI0 Line to PA.00 pin */
      GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource12);
      GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource13);
      GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource14);
      
      /* Configure EXTI line */
    EXTI_InitStructure.EXTI_Line = EXTI_Line12;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  
    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
    EXTI_Init(&EXTI_InitStructure);
    EXTI_InitStructure.EXTI_Line = EXTI_Line13;
    EXTI_Init(&EXTI_InitStructure);
    EXTI_InitStructure.EXTI_Line = EXTI_Line14;
    EXTI_Init(&EXTI_InitStructure);
    

 

    /* Enable and set EXTI0 Interrupt to the lowest priority */
    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQChannel;
    NVIC_Init(&NVIC_InitStructure);
    NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQChannel;
    NVIC_Init(&NVIC_InitStructure);

 

}

 

 

 

void EXTI2_IRQHandler(void)
{
  
        
if(EXTI_GetITStatus(EXTI_Line14) != RESET)
 {
     GPRS_TX_Bytes("INTERRUPT 3-");
     adc_read=1;
    
 }
  EXTI_ClearITPendingBit(EXTI_Line14);
    
    
    
}

 

/*******************************************************************************
* Function Name  : EXTI1_IRQHandler
* Description    : This function handles External interrupt Line 1 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI0_IRQHandler(void)
{
  
if(EXTI_GetITStatus(EXTI_Line12) != RESET)    
 {
    
  
     adc_read=1;
    
 }
  EXTI_ClearITPendingBit(EXTI_Line12);
    
}

 

/*******************************************************************************
* Function Name  : EXTI2_IRQHandler
* Description    : This function handles External interrupt Line 2 request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EXTI1_IRQHandler(void)
{
  
      if(EXTI_GetITStatus(EXTI_Line13) != RESET)
 {
    
   
     adc_read=1;
    
 }
  EXTI_ClearITPendingBit(EXTI_Line13);
    
}

 

 

Kind Regards

Don David

Outcomes