Multiple interrupt source determination


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Location
    Austin, TX
    Posts
    68

    Default Multiple interrupt source determination

    I need to use the bit change interrupt feature on a PIC16F76 and determine which of 4 inputs (RB4-RB7) actally changed. I looked through a multitude of sample interrupt programs but didn't find any that deal with multiple inputs. When a bit change interrupt occurs, I don't see an easy way of determining which specific port bit changed, so the following logic seems necessary.

    Store the state of all 4 (RB4-RB7) inputs

    ' interrupt routine
    compare the 4 ports to the saved state to determine which one changed
    save the input state for the next interrupt
    do something in response to the bit that changed
    reset the interrupt flag
    resume

    Is this the right way to determine which of the 4 inputs caused the interrupt?

    Thanks,

    PickyBiker
    PickyBiker says, "Riding a motorcycle eases programming frustration".

  2. #2
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Correct. You have to read the port anyway (comparing it to the state variable will do it) to clear the mismatch condition.

  3. #3
    Join Date
    Mar 2010
    Location
    Austin, TX
    Posts
    68


    Did you find this post helpful? Yes | No

    Default

    Thanks RMTEO.
    PickyBiker says, "Riding a motorcycle eases programming frustration".

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