di2594l1.txt ;************************************************************************************************** ; LISTING 1 - DEBUGGING SUBROUTINE ; ; "PIC debugging routine reads out binary numbers," EDN, Dec 7, 2000, pg 196 ; http://www.ednmag.com/ednmag/reg/2000/12072000/designideas.htm#25di5 ; *************************************************************************************************** ;Define the pin to be used as the test point: #define TP1 5,4 ;bit 4 of Port A. ;Allocate a register for use by the debug subroutine: cblock DebugReg endc ;--------------------------------------------------------------- ; This subroutine takes the contents of the W register and shifts ; it out, bit by bit, on the TP1 port pin for viewing on a scope. ; Long pulse is a one and short pulse is a zero. W register and ; flags are preserved! Debug movwf DebugReg ;Store value in reg. rlf DebugReg ;Shift MSB into CY. bcf TP1 ;"Start of byte" transition. btfsc C ;If bit is set, bsf TP1 ;start pulse sooner, rlf DebugReg bsf TP1 ;rather than later. bcf TP1 ;End of pulse. btfsc C ;Test next bit and repeat... bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg bsf TP1 bcf TP1 btfsc C bsf TP1 rlf DebugReg ;Restore CY flag. bsf TP1 bcf TP1 nop ;Optional to provide consistent timing. bsf TP1 ;"End of byte" transition. return