2009-05-19 03:33 AM
EXTI0 Interrupt Not Working
2011-05-17 04:00 AM
I have a Hall Effect Sensor Connected to pin B0. The interrupt does not work when falling edge applied (Falling Edge signal verified by scope). the EXTI_GenerateSWInterrupt(EXTI_Line0); function does generate the interrupt and turn on the LED though.
MCU: STM32F103RBT6Code:
/*Initialize the EXTI ints */ void RPM_EXTI_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; /* Enable GPIOA, GPIOB, AFIO clock */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE ); /* Configure EXTI GPIO Pins as Input Pull Up */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource0); /* Configure EXTI Interrupts as Falling Edge */ EXTI_InitStructure.EXTI_Line = EXTI_Line0; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Generate software interrupt: simulate a falling edge applied on EXTI line */ // EXTI_GenerateSWInterrupt(EXTI_Line0); } void EXTI0_RPM1_IRQHandler(void) { //TURN LED ON FOR TESTING GPIO_WriteBit(GPIOB, GPIO_Pin_12, Bit_RESET ); /* Clears the EXTI line 0 interrupt pending bit */ EXTI_ClearITPendingBit(EXTI_Line0); } Any help appreciated. Thanks! Todd2011-05-17 04:00 AM
are you setup NVIC for this source?
for ex. in this way: NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); is EXTI0_RPM1_IRQHandler() execued from stm32f10x_it.c?2011-05-17 04:00 AM
Can you Tell us the Values of
GPIOB->ODR (Bit 0 Should be 1 - to insure theres a pull up) GPIOB->CRL Last 4 Bits should be 1000 (for input pull up) (I suspect you have 1001 which is wrong) EXTI->IMR and EXTI->EMR For Both Bit0 - should be 1 EXTI->FTSR should have bit 0 as 1 EXTI->RTSR should have bit 0 as 0 Ensure the EXTI->PR is cleared (by writing 1 to bit 0) After initialising the interrupt and before the Event occurs :) I'm Afraid i don't use ST's firmware library for setting up the registers so i don't know exactly what things should be set to in that but as the GPIO->CRL is should be set to input rather than a speed (you have GPIO_Speed_10MHz rather than Input) in the register that may be your problem? also check the AFIO->EXTICR[0] the first four bits should be 0001 for GPIOB(0) as the EXTI(0) source Hope this helps G:)2011-05-17 04:00 AM
Hi Todd;
First, you have to configure the NVIC as sayed by lordac. If you are using the GPIOB.0 , you have to configure this pin to generate the EXTI interrupt as following: /* Connect GPIOB.0 pin to EXTI Line 0 */ GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_Pin_0); B.R. M3allem2011-05-17 04:00 AM
Quote:
On 28-01-2009 at 04:39, Anonymous wrote: are you setup NVIC for this source? for ex. in this way: NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); is EXTI0_RPM1_IRQHandler() execued from stm32f10x_it.c? Thank you Lordac, giles, & M3allem for your prompt responses, I seemed to have overlooked the NVIC init of the peripheral. The interrupt is working perfectly now. Thank you! Todd2011-05-17 04:00 AM
I posted a document over at
on this very subject. If any of you want to clarify it then that'd be smashing:)