Help with PORTB Interrupt On Change Please


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166

    Default Help with PORTB Interrupt On Change Please

    Hi All,

    I am looking to use PORTB Interrupt On Change on a PIC18F26J50 but can't get my head around how to determine which pin (PORTB.4 - 7) caused the interrupt.
    I would like to set up four momentary action switches to each of the four PORTB IOC pins (with associated pull up resistors) and then action different sections of code depending on which switch was activated.
    I have searched the FORUM looking for examples but haven't found anything which answers my questions.

    Any assistance and/or guidance would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Help with PORTB Interrupt On Change Please

    one way



    oldportb var byte
    pbchange var byte


    in main before isr enabled
    oldportb=portb





    in isr {portb must have changed to get here}


    pbchange = portb ^ oldportb ; xor portb with last known state and set bits that changed

    oldportb=portb ;update state
    pbchange=pbchange>>4 ; shift result to low byte

    int returm
    Warning I'm not a teacher

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: Help with PORTB Interrupt On Change Please

    Thanks Richard.

    It was the xor process that I was missing.

    Cheers
    Barry
    VK2XBP

Similar Threads

  1. PORTB + PORTC Interrupt-On-Change
    By Aussie Barry in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 26th March 2014, 14:02
  2. PortB Change Interrupts
    By backstabber in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 8th October 2011, 04:52
  3. Replies: 6
    Last Post: - 12th March 2011, 14:11
  4. Returning from Int on PortB change
    By sheryl in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th December 2008, 19:09
  5. Interrupt portb
    By tazntex in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 18th August 2008, 22:05

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