PortB Change Interrupts


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1

    Default PortB Change Interrupts

    I have setup my code to get an interrupt when PortB's Pin 1 or Pin 0 gets triggered. I am using DT's Instant Interrupt and I have created and enabled interrupt processor for RBC_INT. The interrupt routine is called when either one of the pin is triggered (contact closure), however I can't tell exactly which pin was triggered. I am doing something like this:

    TRIGGER0 VAR BIT
    TRIGGER1 VAR BIT

    TRIGGER0 = portb.0
    TRIGGER1 = portb.1

    However, both would read 1. Any idea what I am doing wrong?

    Any help would be greatly appreciated.

    P.S. I am a picBasic novice. Please go easy on me.

  2. #2
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    What pic are you using?
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  3. #3
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    If I am reading the data sheet correctly, the "input change Interrupts" will fire when anything on the port changes. I do not believe the individual pins can be monitored this way. If you need individual pins you may need to use an "external interrupt" and INT_INT.

    Darrel please correct me if I am wrong
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by krohtech View Post
    What pic are you using?
    I am using 18F66J15

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


    Did you find this post helpful? Yes | No

    Default

    RBC_INT only triggers on chages with PORTB<7:4>

    For PORTB.0, you would use INT0_INT
    PORTB.1 is INT1_INT

    Each one should have it's own handler, so it automatically knows which pin triggered.
    <br>
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    RBC_INT only triggers on chages with PORTB<7:4>

    For PORTB.0, you would use INT0_INT
    PORTB.1 is INT1_INT

    Each one should have it's own handler, so it automatically knows which pin triggered.
    <br>
    Actually, I meant to read from pin 4 and 5. That solves half of the problem.

    I have corrected that in my code, still same problem.

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


    Did you find this post helpful? Yes | No

    Default

    Keep in mind that any changes on PORTB.6 or 7 will also trigger an interrupt. It's best to Not Use 6 and 7 for anything else.
    Code:
    Old_Bits VAR BYTE
    New_Bits VAR BYTE
    
    INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,         Label,  Type, ResetFlag?
            INT_Handler    RBC_INT,  _RBC_handler,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    Old_Bits = PORTB
    @    INT_ENABLE   RBC_INT     ;RB Port Change Interrupt
    
    Main:
      Pause 1000
    GOTO Main
    
    '---[RBC - interrupt handler]---------------------------------------------------
    RBC_handler:
        New_Bits = PORTB
        IF (New_Bits.4 <> Old_Bits.4) THEN
            ; -- PORTB.4 has changed -- 
        ENDIF
        IF (New_Bits.5 <> Old_Bits.5) THEN
            ; -- PORTB.5 has changed -- 
        ENDIF
        Old_Bits = New_Bits
    @ INT_RETURN
    DT

  8. #8
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: PortB Change Interrupts

    Quote Originally Posted by Darrel Taylor View Post
    RBC_INT only triggers on chages with PORTB<7:4>
    <br>
    Darrel, I know this statement was related to a posting for a 18F66J15, but I am trying to use RBC_INT for PortB.2 and PortB.3 on a 16F886. I had a design going on a 18F2550 that used INT2_INT on PortB2 and worked well. However, for reasons I won't go into here I had to move the design to a 16F886 and continue to use PortB.2 and PortB.3 as interrupt inputs from the alarm pins on a DS1337 RTC. I already have PCBs built originally for the 28-pin 18F2550 and am trying to salvage them without trace changes by substituting a 28-pin 16F886 on the same board layout. My question...is there anyway I can use RBC_INT on the PortB.2 and PortB.3 pins of a 16F886 and monitor which pin actually received the interrupt? I have noted your OLDPORT vs NEWPORT technique to do this kind of interrupt isolation and presume I can do this on my 16F886 if RBC_INT will work ont these ports? Can you help me out here?

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


    Did you find this post helpful? Yes | No

    Default Re: PortB Change Interrupts

    John,

    On the 16F88x's use IOC_INT (Interrupt On Change).

    Set the pins you want to monitor in the IOCB register.
    DT

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. Returning from Int on PortB change
    By sheryl in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th December 2008, 18:09
  3. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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