18F4550, How to use multiple External Interupts


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: 18F4550, How to use multiple External Interupts

    Ok someone else just posted an article with INT's and a response looks very good, first look at my original post code, this works for one interupt, now heres the code that made me interested (if this is part of darrels routines let me know)

    Code:
    INTCON2.6 = 0   'Interrupt on falling edge of INT0
    INTCON2.5 = 1   'Interrupt on rising edge of INT1
    
    ' Here two interrupts are declared. One for INT0 (PortB.0) and one for INT1 (PortB.1). 
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT0_INT,  _RcvCAN,   PBP,  yes
            INT_Handler    INT1_INT,  _DoSomething, PBP, yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    Main:
      Pause 100
      Toggle LED
    Goto Main
    
    RcvCAN:
    ' Put your code here or GOSUB it but make SURE you have a RETURN at the end of the routine so you come back here, otherwise you'll crash.
    @ INT_RETURN
    
    DoSomethingElse:
    Toggle AnotherLED
    @ INT_RETURN
    now if this is darrels way then I can see the ease of use, im not sure why INT0 and INT1 have falling and leading edge differnt but thats ok. I would like to know how to alter my original code to use 3 interupts though?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 18F4550, How to use multiple External Interupts

    Hi,
    Yes, this is an example of how to use DT-INTS, if you want more information on it I strongly suggest that you
    A) Check Darrels website and all his examples and
    B) Search the forum because there's been a TON of examples and discussions on these great routines over the years.

    im not sure why INT0 and INT1 have falling and leading edge differnt but thats ok
    That was just to show that you CAN select on which edge the interrupt should fire. You want them both (or all three including INT2) on the falling edge then you set them up that way.

    I would like to know how to alter my original code to use 3 interupts though?
    Using ON INTERRUPT:
    First you set up the three interrupts you want to use and enable them, just like you've done with INT0 in your working example. To determine which of the three interrupts that fired you check the three individual interrupt flags in your interrupt service routine and act accordingly. Before you leave the interrupt service routine you clear the interrupt flag that caused the interrupt. (I thought we covered that earlier in the thread).

    /Henrik.

Similar Threads

  1. Help with interupts
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd October 2011, 18:46
  2. External Eeprom - trying to store multiple variables
    By bluesmoke in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th April 2010, 02:07
  3. Can I have interupts on any pin ?
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 17th March 2010, 15:19
  4. DT Interupts and ICD?
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th November 2009, 02:02
  5. Multiple External Interupts
    By w7ami in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st May 2007, 22:56

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