Вы находитесь на странице: 1из 2

;************************************************************************

;
*
; Filename:
delay10-shr.asm
*
;************************************************************************
;
*
; Architecture: Midrange PIC
*
; Processor:
any
*
;
(best suited to devices such as 16F676 with no
*
;
banked memory)
*
;
*
;************************************************************************
;
*
; Files required: none
*
;
*
;************************************************************************
;
*
; Description:
Variable Delay : N x 10ms (10ms - 2.55s)
*
;
*
;
N passed as parameter in W reg
*
;
exact delay = W x 10.015ms
*
;
*
; Returns: W = 0
*
; Assumes: 4MHz clock
*
;
*
; USES SHARED MEMORY FOR VARIABLES
*
;
*
;************************************************************************
#include

<p16F676.inc>

GLOBAL

delay10

;***** VARIABLE DEFINITIONS


UDATA_SHR
dc1
res 1
dc2
res 1
dc3
res 1

; any midrange device will do

; delay loop counters

;************************************************************************
CODE
delay10
dly2
dly1

banksel
movwf
movlw
movwf
clrf
decfsz
goto
decfsz
goto
decfsz
goto
return

dc3
dc3
.13
dc2
dc1
dc1,f
dly1
dc2,f
dly1
dc3,f
dly2

; delay W x 10ms
; -> ?+1+Wx(3+10009+3)-1+4 = Wx10.015ms
; repeat inner loop 13 times
; -> 13x(767+3)-1 = 10009 cycles
; inner loop = 256x3-1 = 767 cycles
; end middle loop
; end outer loop

END

Вам также может понравиться