cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI0 Interrupt Not Working

tberk1
Associate II
Posted on May 19, 2009 at 12:33

EXTI0 Interrupt Not Working

6 REPLIES 6
tberk1
Associate II
Posted on May 17, 2011 at 13:00

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: STM32F103RBT6

Code:

/*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!

Todd

lordac
Associate II
Posted on May 17, 2011 at 13:00

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?

giles
Associate II
Posted on May 17, 2011 at 13:00

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:)

sofiene
Associate III
Posted on May 17, 2011 at 13:00

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.

M3allem

tberk1
Associate II
Posted on May 17, 2011 at 13:00

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!

Todd

nacnud_uk27
Associate II
Posted on May 17, 2011 at 13:00

I posted a document over at

http://wiki.fosstronics.com/exti_notes

on this very subject. If any of you want to clarify it then that'd be smashing:)