You mean this:If so then it's the same potential issue. The PIC runs thru this short program in a couple of microseconds (lets say 20), except for the PAUSE 20 where it spends 99.9% of its time. The likelyhood of the button being pressed during this time and therefor NOT cause the output to toggle is 999 in 1. In the initial code the PAUSE was even longer further decreasing the chanse of the button being polled outside of the debounce routine. Run the code, press the button a few thousand times it "should" toggle the output at least once.Code:Progstart: if PORTB.0 = 1 then Toggle PORTB.6 endif Debounce: Pause 20 ' ? shorter ? If PORTB.0=1 then goto Debounce ' Button still pressed? endif Goto Progstart
That's my theory and I'm sticking to it until someone comes up with a better one :-)
/Henrik.




Bookmarks