How to enable two interrupts?


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default How to enable two interrupts?

    Hi,
    I have one interrupt working but now would like to enable a second. The first one is a Timer2 match interrupt. The Pic is a 16f1829. I use other Pics in this same family as well. They all operate with automatic context saving so I write my interrupt handlers in assembly. When I add a second INTHAND I get an error message "duplicate handler". Maybe this should not be a big surprise. In any case, are there suggestions?
    Last edited by Dick Ivers; - 14th November 2015 at 17:06. Reason: spelling

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: How to enable two interrupts?

    Hi again,
    I'm taking a stab at a possible solution to my own problem:

    Of course there cannot be two interrupt handlers. So, within the single handler a test could be made to determine which of the two interrupt flags is set. Then, based on that test, branch to the appropriate handler steps for that interrupt. All within one handler.

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: How to enable two interrupts?

    Dick,

    I think your on to the right answer...
    Here is what I did to detect between a timer overflow vs a button push with a 12f683

    Code:
    MyInt:
      
      inttype = PIR1 & %00000001  'check if timer1 overflow occured
      if inttype = 1 then goto TimerInt
      
      goto buttonint  'interrupt was gpio.3
    then i clear the interupt flag here...
    Code:
    ExitInt:
       intcon.0 = 0
       PIR1.0 = 0
       resume
    
    enable
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: How to enable two interrupts?

    That is correct. That is what the interrupt flags are for, to allow the interrupt routine determine which interrupt occured.
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. Disable/Enable DT interrupt
    By aratti in forum PBP3
    Replies: 10
    Last Post: - 16th June 2018, 16:50
  2. Disable/Enable in Interrupts
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th June 2015, 07:47
  3. DT_INTS-14 /interrupts enable bits / flag bits
    By bogdan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th May 2009, 18:42
  4. Enable and Disable in Interrupts
    By stevecrunch in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th October 2007, 01:10
  5. ENABLE command not always mandatory?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd October 2006, 18:11

Members who have read this thread : 1

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