An88 – Cirrus Logic AN88 User Manual
Page 12

AN88
12
AN88Rev2
;*************************************************************************************
;* Routine - delay
;* Input
- Count in register A
;* Output - none
;* This subroutine delays by using count from register W. The PIC16F84
;* development board uses a 10 MHz clock (E = 2.5 MHz), thus each cycle is
;* 400 nS. This delay is approximately equivalent to
;* (400ns)*(1545)*(count value), (a count of 720 provides a 445ms delay).
;*************************************************************************************
delay
MOVWFCOUNT
; Put the delay count into COUNT
outlp
CLRF
TEMP
; TEMP used as inner loop count
innlp
NOP
; 1 cycle
NOP
; 1 cycle
NOP
; 1 cycle
NOP
; 1 cycle
DECFSZ
TEMP,1
; FF-FE, FE-FD, ....1-0 256 loops
; 10 cycles*256*500ns=1.28 ms
goto
innlp
; If count not done repeat loop
DECFSZ
COUNT,1
; Countdown the accumulator
goto
outlp
; 2569 cycles*500ns*A
RETURN
; Exit subroutine
;*************************************************************************************
;* Interrupt Vectors
;*************************************************************************************
NOT_USED RETFIE
ORG
0x04
; Originate Interrupt Vector here
goto
NOT_USED
; No Interrupts Enabled
end
; End Program Listing