; ; *************************************************************************** ; *** Bubble Software Parallax to PIC Source Converter. Copyright 1999. *** ; *** http://www.picnpoke.com email: sales@picnpoke.com *** ; *************************************************************************** ; ; PAUSE time ; A general-purpose delay routine that puts the PIC into a do-nothing ; loop for a 16-bit number of milliseconds (1 to 65535) at 4 MHz. Requires ; 16 cycles of overhead for call, return and other processing. P = pic16c55 #include <16c55.inc> ; processor assembler definitions _CONFIG _xt_osc & _wdt_off & _protect_off reset start org 8 hiB Res d'1' ; MSB of time. lowB Res d'1' ; LSB of time. temp Res d'1' ; temporary counter for Pause ; Device data and reset vector org 0 start MOVLW d'0' ; Output through RB. TRIS 6h MOVLW d'3' ; Length of delay = MOVWF hiB MOVLW 0x00E8 ; 3E8h (1000 ms @ 4MHz). MOVWF lowB MOVLW d'255' ; Toggle LED(s). XORWF 6h CALL Pause ; Wait 1 second. GOTO start ; Do it again. ; Upon entry, variables hiB and lowB hold the MSB and LSB of the ; number of milliseconds (1 to 65535) to delay. Pause COMF hiB ; Take twos complement COMF lowB ; of the 16-bit counter INCF lowB BTFSC status,z ; If zero, lowB overflowed, INCF hiB ; so carry into hiB. Pause_load MOVLW d'248' ; Set up for 1-ms loop. MOVWF temp Pause_loop NOP ; Do nothing. DECFSZ temp ; Do more nothing. GOTO Pause_loop GOTO $+1 ; 2-cycle "nop" INCF lowB ; lowB = lowB+1. BTFSC status,z ; Overflow in lowB? INCFSZ hiB ; Yes: hiB=hiB+1, overflow?. GOTO Pause_load ; No overflow: do it all again. RETLW 0h ; Overflow. Return to caller. end