Skip to main content
Visitor II
September 19, 2007
Question

Timer 0 Interrupt entered 2 times

  • September 19, 2007
  • 7 replies
  • 1317 views
Posted on September 19, 2007 at 17:27

Timer 0 Interrupt entered 2 times

    This topic has been closed for replies.

    7 replies

    Visitor II
    May 17, 2011
    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.

    mgerkens9Author
    Visitor II
    May 17, 2011
    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

    mgerkens9Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:43

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

    Visitor II
    May 17, 2011
    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

    mgerkens9Author
    Visitor II
    May 17, 2011
    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 :)

    Visitor II
    May 17, 2011
    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

    Visitor II
    June 26, 2012
    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.