2014-11-24 12:35 PM
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); }}2014-11-24 01:07 PM
Pin 11 -> EXTI 11, not 0 or 1
2014-11-24 02:07 PM
What a dumb mistake. Thanks for the reply!