2009-10-05 07:54 AM
problem using ext interrupt
2011-05-17 04:10 AM
Hello, I have a problem using external interrupts on my STM32f103ZE.
The interrupts keep coming , while there is no activity on the input pin. I set it up like this: The clock for external int is running ( /* Enable the EXTI Clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);) Used a pin for ext int: /* Configure RAIN Interrupt */ GPIO_EXTILineConfig (RAIN_INT_GPIO_SOURCE, RAIN_INT_PIN_SOURCE); EXTI_InitStructure.EXTI_Line = EXTI_Line5; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); EXTI_ClearFlag (EXTI_Line5); The pin is configured mode in floating, and held high by an external resitor. I can read the pin correctly with GPIO_ReadInputDataBit I clear the interrupt bits in the handler EXTI_ClearFlag (EXTI_Line5); /* Clear the EXTI line pending bit */ EXTI_ClearITPendingBit(EXTI_Line5); But the Flag EXTI Line 5 seems to set automaticaly after it is RESET. And all the time, an interrupt is coming, so the code in the handler is executed. Can anyone help?2011-05-17 04:10 AM
you set the interrupt to respond to a rising edge but you said that the actual pin in pulled high this would mean that interrupt is always TRUE therefore why it keeps going back to the interrupt routine, you do clear the flag in the handler but immediately after you exit it gets triggered again because is high. if a pin is pulled high then the interrupt should be set up on a falling edge because thats how interrupts work, they work on a change of state( dont mean to talk you down, just trying to explain the problem as clear as possible everybody has made this mistake ) hope this helps
2011-05-17 04:10 AM
Hi jramirez,
sorry I'm not so comfortable with some parts of your response: you said '' interrupt is always TRUE therefore why it keeps going back to the interrupt'' On my knowledge the interrupt is sensitive to the transition time (I mean when crossing VCC/2, and normally when we are in a static level we should not have any interrupt. so could you please clarify :-[ ? Regards, arm.2011-05-17 04:10 AM
yes you are correct the interrupt should only work on a transition, but from personal experience with the stm32 i know that if an interrupt is set the way yo described and tends to not work properly. in theory what you did should work, i dont know why you are doing it that way, do you wan the interrupt to occur after the actual event ie.
push button interrupt on release not on push. if you wanted it this there is another parameter you can pass to the EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; you could use instead: EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; which would give you what you want i think and shouldnt trigger the interrupt all the time, give that a try and see if it works hope this helps you more2011-05-17 04:10 AM
I am having the same problem with my interrupts.
I am not using a button, but the clock from another device. It is a falling-edge that I am looking for, but it appears that the interrupt keeps getting called as if it was level-sensitive, not edge triggered. I cannot seem to find a description of how to make a signal explicitly edge-triggered in the documentation. I also don't think that I should be responsible for clearing the pending bit. What is EXTI_MODE_INTERRUPT and EXTI_MODE_EVENT? Do they make things happen differently?2011-05-17 04:10 AM
Hi jschatz
Can you paste you configuration for GPIO NVIC and EXTI for that specific port also I found in a lot examples that they always clearing the pending bit I have been using external interrupts for many thing from Button int to RF module and GSM modem int without an issue here is my set up / /* Configure RING PIN GPIOA Pin10 as internal pull-down */ GPIO_InitStructure.GPIO_Pin = GPIO_PIN_RING; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIO_RING, &GPIO_InitStructure); GPIO_EXTILineConfig(GPIO_PORT_SOURCE_RING, GPIO_PIN_SOURCE_RING); /* Configure Key Button EXTI Line to generate an interrupt on rising edge */ EXTI_InitStructure.EXTI_Line = EXTI_LINE_RING; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable the Ring Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = NewState; NVIC_Init(&NVIC_InitStructure); let me know if you need more help [ This message was edited by: jramirez on 02-10-2009 22:22 ]2011-05-17 04:10 AM
Be aware that EXTI has quite a sensitivity on short pulses (