cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI causes program hang

jaroslaw2
Associate II
Posted on July 25, 2009 at 21:20

EXTI causes program hang

3 REPLIES 3
jaroslaw2
Associate II
Posted on May 17, 2011 at 13:09

I have discovered that program sometimes stuck in EXTI interrupt forever. It is difficult to localize the problem because it happens once per hour.

I do not use any sleep modes as referred in errata.

I use two instructions to manage disable/enable interrupt.

EXTI->IMR &= ~EXTI_Line6;

EXTI->IMR |= EXTI_Line6;

This instructions are executed asynchronously in other places in my program.

There is at least one situation where program do not return from the ISR because it happens. I have checked my ISR in case of death loops.

Any ideas?

jaroslaw2
Associate II
Posted on May 17, 2011 at 13:09

I have found the error.

If there is instruction,

EXTI->IMR &= ~EXTI_Line6

inside ISR in moment when IT pending bit is on. Program stops in ISR and I do not know why?

Please try example,

Code:

void EXTI9_5_IRQHandler(void)

{

if(EXTI_GetITStatus(EXTI_Line6) != RESET){

EXTI_ClearITPendingBit(EXTI_Line6);

asm(''nop'');

asm(''nop'');

asm(''nop'');

asm(''nop'');

asm(''nop'');

//Another EXTI arrives.

asm(''nop'');

asm(''nop'');

asm(''nop'');

EXTI->IMR &= ~EXTI_Line6;

//hang :\

}

Can somebody check or comment it?

16-32micros
Associate III
Posted on May 17, 2011 at 13:09

Dear jaroslaw.oska,

This is a normal behavior , the CPU will stucked in the EXTI ISR and the interrupt pending bit will not be cleared . If another EXTI just arrives before disabling the interrupt request bit in the EXTI_IMR register (“EXTI->IMR &= ~EXTI_Line6;), the EXTI line pending bit will be set and the ISR will be again served and then it is expected that the CPU will stuck in the ISR. This is due to the usage of EXTI_GetITStatus function.

In your EXTI ISR you are using the EXTI_GetITStatus(EXTI_Line6) != RESET), and when the EXTI ISR is served the interrupt request bit has been disabled. Therefore the EXTI_GetITStatus will always return RESET despite of the pending bit is set. As a result, you will never be able to clear the pending bit and CPU will get stuck in the EXTI ISR.

The purpose of using the EXTI_GetITStatus is to return a status SET when the pending bit for the EXTI line has been set and the interrupt request should be also set. If the Interrupt request of this EXTI line is reset as in your case, the EXTI_GetITStatus will always returns a RESET status and you will not be able to clear the pending bit. If you need to disable the EXTI line, you have to use the EXTI_GetFlagStatus function instead and your problem should be solved.

Hope this helps you. :)

Cheers,

STOne-32.