Interrupt on change always being called

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Mar 17, 2013.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    I have an interrupt on change event for 3 pins on a p18f14k22. RB4, RB5 and RB6 all have a pullup resistor with N.O. push buttons connecting to ground on press.

    On RB4 it is working as expected. I get two interrupts. One on the press and one one the release, But for RB5 and RB6, I only get an interrupt when the push button is released. I don't get one on press.

    I will post schematic and code later if requested. Just wanted to post this to see if any one knows right off what could be causing this issue.
     
  2. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    When the interrupt occurs you MUST read PORTB to clear any mis-matching of the port

    The last known port condition is OR'd with the new state so If you don't physically read the port the change may be not what you expect...
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    l am reading port B. Sorry for the incorrect subject. This was my orginal issue. Can a mod please change it to "Interrupt on change only being called once"?
     
  4. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    I see what I was doing wrong. I was reading the port 3 times. I was reading each pin one at a time. Apparently this causes issues.
     
  5. Ian Rogers

    Member

    Dec 12, 2012
    158
    29
    So is it working now???
     
  6. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    Sorry I thought that was clear above. I do have another related issue but I think I will start another thread.
     
Loading...