Bob Blick wrote: > > Does anyone have a slick method for detecting rising or falling edges? I > keep ending up with a variation of these two methods, and both seem cheesy. > In this case I am trying to detect a falling edge on PORTA,4 and jump to > Index_now. I am using index_flag for storage. > > Anybody got a quantum leap for me? > Try this untested code: MOVF PORTA,W ;Get the current state of PORTA,4 XORWF index_flag,W ;Compare to the saved state. ANDLW 1<<4 ;Only interested in PORTA,4 SKPNZ goto no_change ;Change in states was detected XORWF index_flag,F ;Save state for next time. ;"Index_now" code goes here. no_change You may get one spurious detection the first time through. If that's really a problem, then initialize index_flag with the current state of PORTA,4. Check out a variation of this "edge-detection" algorithm in my debouncing algorithm: http://www.interstice.com/~sdattalo/technical/software/pic/debounce.html Scott