Timer Interrupts


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default Timer Interrupts

    Hi Again Everyone;

    Help me out on this doubt;

    Lets forget from a little moment, abour rule number one of interrupts. ( Get in, and get out ASAP )

    If i have im my code 2 interrupts, one from timer1 that interrupts every 10mS, and other from timer2 that interrupts every 3mS. Inside the ISR of the timer1, i have a piece fo code that takes 8mS to complete, and on timer2 i have a routine that takes 2ms.

    My doubt/question, is, what will happen when timer1 is trigger, and during the execution of the code inside the ISR, timer2 triggers also?
    Thanks and Regards;
    Gadelhas

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    While inside the ISR, interrupts are disabled (the GIE bit is cleared by hardware).
    So it will wait until the current interrupt source has been serviced before handling the next one.
    Unless you are using low priority interrupts, which can be interrupted by high priority interrupts.

    If you are using ON INTERRUPT, the question would be irrelevant.
    DT

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    Quote Originally Posted by Darrel Taylor View Post
    While inside the ISR, interrupts are disabled (the GIE bit is cleared by hardware).
    If you are using ON INTERRUPT, the question would be irrelevant.
    Thank you Darrel. Actually i'm using DT ints made by you!!!

    So when the timer1 interrupt triggers, goes to the ISR and disable all the interrupts, when the ISR is completed it turns on all the interrupts again, thats it?
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    ..........
    Unless you are using low priority interrupts, which can be interrupted by high priority interrupts.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    Quote Originally Posted by mister_e View Post
    ..........
    Ok, steve, lets see, if my timer1 is low priority, and timer2 is high priority. The timer interrupts and starts to execute the code inside the ISR, meanwhile the timer2 triggers, since is high priority jumps to its own execution. What will hapen?
    After the ISR of the timer2 finishs it jumps again to the ISR of the timer1 to the place where it was interrupt by timer2?
    Thanks and Regards;
    Gadelhas

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    Quote Originally Posted by gadelhas View Post
    Ok, steve, lets see, if my timer1 is low priority, and timer2 is high priority. The timer interrupts and starts to execute the code inside the ISR [low priority], meanwhile the timer2 triggers, since is high priority jumps to its own execution. What will hapen?
    The next address that would be executed in the Low Priority ISR is pushed onto the stack and then the program branches to the location of the High Priority ISR (0008h), where it begins to execute that code.

    Quote Originally Posted by gadelhas View Post
    After the ISR of the timer2 finishs it jumps again to the ISR of the timer1 to the place where it was interrupt by timer2?
    Yes. It pulls the address off the stack and branches back to the low priority ISR.

    It will also set the global enable bit for the High Priority interrupts, so that if another High Priority interrupt occurs, it will branch again to that ISR. (Which is why it is critical to reset the interrupt flags in the ISR)

    Eventually, it should finish with the Low Priority ISR and branch back to the main program flow. (This will also set the global enable bit for Low Priority interrupts)

    Clear as mud?

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    I think your interrupts may interfere with each other. Tell me if I'm wrong but you should only stay in int for 10-20-50 micro secs, raise some flag if necessary and let basic code do the longer work.

    don
    amgen

  8. #8
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    Quote Originally Posted by amgen View Post
    I think your interrupts may interfere with each other. Tell me if I'm wrong but you should only stay in int for 10=20=50 micro secs, raise some flag if necessary and let basic code do the longer work.

    don
    amgen

    I kown that! See my first post! I´m trying to understand the theory better, and what will happen in the case that i posted!!
    Thanks and Regards;
    Gadelhas

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Timer Interrupts

    yes, your way ahead. delete my post ......

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts