> I am trying to use a push button to trigger the > external interrupt of RB0. However I need to implement > a s/w deboucing in my code to prevent multiple > triggering of the interrupt. > How do I go about writing the code for the s/w > deboucing? (using delays?) If you truly want to prevent "multiple triggering of the interrupt", then you need to debounce in hardware. Do you need the button on the interrupt? I guess I wouldn't use the interrupt feature of portb.0 with a bouncy push button. If you are just looking for button presses, I would establish a periodic interrupt like Olin mentioned, and poll the input with a software debounce. I don't like using delays for this type of debounce - there's usually other stuff that needs to get done. Here's some pseudo code (is there an official way to write pseudo code??) that hopefully illustrates one way to get a 50 ms debounce: - happens every 1 ms via a timer based interrupt (but I don't like stuff like this in the actual isr) - variables: BUTTON_STATE, DEBOUNCE_COUNTER - use BUTTON_STATE, not PORTB.0 for any button based decisions in the rest of your code if (PORTB.0 not equal to BUTTON_STATE): increment DEBOUNCE_COUNTER else: DEBOUNCE_COUNTER = 0 if (DEBOUNCE_COUNTER equal 50): toggle BUTTON_STATE DEBOUNCE_COUNTER = 0 Sometimes processing is required at the transition (for example, save data when the button is released). When BUTTON_STATE is toggled, either flag that a transition occurred, or do whatever processing is required. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu