PIC Pic all write 010c pic doc PAUSE.pdf

(11 KB) Pobierz
PAUSE.htm
;
;
;
;
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.
org
ds
ds
ds
8
1
1
1
hiB
lowB
temp
; MSB of time.
; LSB of time.
; temporary counter for Pause
; Device data and reset vector
device pic16c55,xt_osc,wdt_off,protect_off
reset
start
org
0
start
mov
mov
mov
XOR
CALL
jmp
!rb, #0
hiB,#3
lowB,#0E8h
rb,#255
PAUSE
start
;
;
;
;
;
;
Output through RB.
Length of delay =
3E8h (1000 ms @ 4MHz).
Toggle LED(s).
Wait 1 second.
Do it again.
:blink
; Upon entry, variables hiB and lowB hold the MSB and LSB of the
; number of milliseconds (1 to 65535) to delay.
PAUSE
NOT
NEG
snz
inc
mov
nop
djnz
jmp
inc
snz
incsz
jmp
ret
hiB
lowB
hiB
temp,#248
temp,:loop
$+1
lowB
hiB
:load
;
;
;
;
;
;
;
;
;
;
;
;
;
Take twos complement
of the 16-bit counter
If zero, lowB overflowed,
so carry into hiB.
Set up for 1-ms loop.
Do nothing.
Do more nothing.
2-cycle "nop"
lowB = lowB+1.
Overflow in lowB?
Yes: hiB=hiB+1, overflow?.
No overflow: do it all again.
Overflow. Return to caller.
:load
:loop
BACK
file:///D|/Electronice/Programe/Microcontrolere&PIC/Pic%20all%20write%20010c/pic_doc/PAUSE.htm08.08.2003 03:53:05
Zgłoś jeśli naruszono regulamin