cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 EXTI not triggering

danielblesener9
Associate II
Posted on November 24, 2014 at 21:35

Code is very simple. I have checked it again and again but cannot get the interrupt to trigger. The interrupt does trigger if I use the software interrupt command. Anybody see the bug? I am outputting a 150Hz 3.3V square wave into the port. No grounding issues. I have verified on a scope.

void EXTI0_Config(void)

{

    EXTI_InitTypeDef   EXTI_InitStructure;

    NVIC_InitTypeDef   NVIC_InitStructure;

    GPIO_InitTypeDef   GPIO_InitStructure;

  /* Enable GPIOA clock */

  RCC_APB2PeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

 

  /* Configure PA.00 pin as input floating */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

 

  /* Enable AFIO clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource11);

 

  /* Configure EXTI0 line */

  EXTI_InitStructure.EXTI_Line = EXTI_Line0;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; // or Falling if button shorts to ground

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

 

  /* Enable and set EXTI0 Interrupt to the lowest priority */

  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

void EXTI0_1_IRQHandler(void)

{

  if(EXTI_GetITStatus(EXTI_Line0) != RESET)

  {

    count1++;

  

    opt_angle = 3600*(count1 + count2)/1024;

    /* Clear the EXTI line 0 pending bit */

    EXTI_ClearITPendingBit(EXTI_Line0);

  }

  if(EXTI_GetITStatus(EXTI_Line1) != RESET)

  {

    count2++;

    opt_angle = 3600*(count1 + count2)/1024;

  

    if(opt_angle >= 3600){

        count1 = 0;

        count2 = 0;

        opt_angle = 0;

    }

    /* Clear the EXTI line 0 pending bit */

    EXTI_ClearITPendingBit(EXTI_Line1);

  }

}

2 REPLIES 2
Posted on November 24, 2014 at 22:07

Pin 11 -> EXTI 11, not 0 or 1

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
danielblesener9
Associate II
Posted on November 24, 2014 at 23:07

What a dumb mistake. Thanks for the reply!