cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 0 Interrupt entered 2 times

mgerkens9
Associate II
Posted on September 19, 2007 at 17:27

Timer 0 Interrupt entered 2 times

7 REPLIES 7
akaiser9
Associate II
Posted on May 17, 2011 at 09:43

When an interrupt is acknowledged immediatly prior to the return from the handler, the interrupt may still be present at the interrupt controller at the time the interrupt level is reenabled, due internal delays.

mgerkens9
Associate II
Posted on May 17, 2011 at 09:43

i all,

i have the following problem:

I run the timer 0 in Output Compare 1 Mode with the interrupt enabled cause i need an 1ms Clock. Now, when an Interrupt occurs, i toggle an LED and i see on my Scope, that the IRQ-Routine is entered 2 times directley next to each other. I have attached my Source-Code.

Thanks for Help

And i also work not with the complicated Libs from ST, i directly uses the Register !!!

Michi

mgerkens9
Associate II
Posted on May 17, 2011 at 09:43

So, what can i do? Takes it so much time to delete the Interrupt-Flag?

Posted on May 17, 2011 at 09:43

did you try to move the

TIM0_SR &=~ TIM0_SR_OCF1;

at the end of irq routine?

I presume that for some reason the

code inside the irq generate a spurius irq.

I use a different configuration for the timer irq:

I configured the timer as pwm: in this way I don't need

to re-arm the counter.....

Ste

mgerkens9
Associate II
Posted on May 17, 2011 at 09:43

Stev, thanks a lot. I use the PWM-Mode and when i clear the TIM_SR register at the end of the interrupt-routine, it works fine. But when i clear the bit at the beginning of the interrupt-routine, it will request also 2 times the isr.

thanks 🙂

mark9
Associate II
Posted on May 17, 2011 at 09:43

Does any one know exactly how many cycles you need to delay clearing the timer interrupt flag? ''At the end'' is sort of vague...

-Mark

gupta2
Associate II
Posted on June 26, 2012 at 10:10

Hi Michi...

We are also facing exactly the same problem with timer in OCM mode..interrupt code executed twice w.r.t one interrupt..have u found solution for your problem. If yes, please share.