

;------Adjustable delay-----10-2550 ms(2.55 seconds)------------
                   ; delay = W x 10ms
			; enter with multiplier in WREG before CALL					

#define adj_del_ms_asm      
;#include	 <p18F13K22.inc>
#include	 <p18F14K22.inc>
#INCLUDE "Adj_delay_ms.inc"                   
#INCLUDE "text.inc" 
  
tempdat access_ovr ;0x30
;tempdat	udata_ovr 0x50
dc1    res 1      
dc2    res 1                   
dc3	   res 1

ADJ_DEL_MS_CODE code                   
  


adj_del_ms:
        movwf   dc3             
dly2    movlw    .130 ; 40MHz;.13             ; 65 20mhz ; repeat inner loop 13 times 4mhz
        movwf   dc2             ; -> 13x(767+3)-1 = 10009 cycles
        clrf    dc1             ; inner loop = 256x3-1 = 767 cycles
dly1    decfsz  dc1,f           
        goto    dly1
        decfsz  dc2,f           ; end middle loop
        goto    dly1            
        decfsz  dc3,f           ; end outer loop
        goto    dly2
        return

		end