General Question About Multiple Interrupts


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hello again!

    Thank You for all the replies. It actually is a lot clearer to me now. I think I understand the concept much better. I will try to handle all interrupts in the system clean and fast without any calls to external sub routines.

    Thank again!

    greg

  2. #2
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    I've used this technique with multiple interrupt sources. At the start of the interrupt routine, after saving your context (if necessary), I test all of the interrupts possible, in order of priority, and the first one ON has a goto to the handler code for that specific interrupt. (For very short handlers, you can also use short IFs or Select Case--but this is less readable if the handler code is more than just a few lines.) After these tests, I return from the interrupt... but each interrupt handler ends with a goto the test segment. That way if another interrupt occurs while I'm in a handler, then it is still handled.

    Like this psuedo code...

    Int_Service:
    {save your context if necessary}
    Int_Tests:
    if Timer1IntActive = IntOn then Timer1Handler
    if Timer2IntActive = IntOn then Timer2Handler
    {restore context if necessary}
    resume

    Timer1Handler:
    {handle the interrupt & reset it}
    goto Int_Tests

    Timer2Handler:
    {handle the interrupt & reset it}
    goto Int_Tests

    --but, it does take up a slight bit more code. You could simply resume at the end of each handler, but then you'd have to repeat the context saving code if your interrupts occur at the same time.

Similar Threads

  1. Timer0 Instant Interrupts Question
    By wmarchewka in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2009, 05:29
  2. Serial Question + General Review
    By Freman in forum General
    Replies: 2
    Last Post: - 20th June 2008, 22:27
  3. Multiple HPWM question
    By Johan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th October 2007, 13:00
  4. Handeling multiple Interrupts
    By BobSpencerr in forum General
    Replies: 15
    Last Post: - 1st March 2007, 01:12
  5. Turning on & off multiple interrupts
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th June 2005, 17:50

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