PIC all write 010c pic doc PULSOUT.pdf
(
13 KB
)
Pobierz
PULSOUT.htm
;
;
;
;
;
;
PULSOUT port, pin, time
Generates an output pulse in 10-cycle (10 us at 4 MHz) units,
based on a 16-bit (1 to 65,535) value. The pulse is the reverse
of the pin's state when pulsout is called. For instance, if the
specified pin is initially 1, Pulsout will invert it to make a
negative-going pulse.
org
ds
ds
ds
ds
ds
8
1
1
1
1
1
hiB
lowB
pin
temp
temp2
; MSB of time.
; LSB of time.
; Pin number to pulse (0-7).
; Temporary variables for time delay
; between pulses
; Device data and reset vector
device pic16c55,xt_osc,wdt_off,protect_off
reset
start
org
0
; Table to convert pin number (0-7) into bit mask (00000001b to 10000000b).
Pinz
jmp
pc+w
retw
1,2,4,8,16,32,64,128
start
mov
clr
mov
clr
mov
mov
CALL
CALL
jmp
!ra, #0
ra
lowB,#10
hiB
pin,#2
w,#0
PULSOUT
delay
start
; All outputs.
; Start with 0s.
; 10 x 10-cycle pulse
;
;
;
;
;
Pin 2.
of port ra.
Pulse pin high for 100 cycles.
Wait a while between pulses.
Do it again.
;
;
;
;
Upon entry, the desired pin must already be set up as an output.
The w register contains a number representing the output port (0-2) for
RA through RC. Variable "pin" contains the pin number (0-7). The variables
hiB and lowB are the MSB and LSB of the time argument.
fsr,w
fsr,#RA
w,pin
Pinz
pin,w
; Point to the port number.
; Add offset for port RA.
; Get bit mask from the table.
; Put the mask into pin
PULSOUT
mov
add
mov
CALL
mov
file:///D|/Electronice/Programe/Microcontrolere&PIC/Pic%20all%20write%20010c/pic_doc/PULSOUT.htm (1 of 2)08.08.2003 03:52:52
PULSOUT.htm
NOT
NEG
snz
inc
XOR
hiB
lowB
hiB
indirect,pin
;
;
;
;
;
Take twos complement
of the 16-bit counter
If zero, lowB overflowed,
so carry into hiB.
Invert the selected pin.
; The main timing loop. Remove the nops for 5-cycle resolution.
:loop
jmp
$+1
; Two-cycle "nop."
jmp
$+1
; Two-cycle "nop."
nop
inc
lowB
; lowB = lowB+1.
snz
; Overflow in lowB?
incsz
hiB
; Yes: hiB=hiB+1, watch for overflow.
jmp
:loop
; If not overflow, do it again.
XOR
indirect,pin
; Invert pin (back to initial state).
ret
; Delay routine for demonstration. Not required by Pulsout.
delay
djnz
djnz
ret
temp,delay
temp2,delay
; Time delay to provide spacing
; between pulses.
BACK
file:///D|/Electronice/Programe/Microcontrolere&PIC/Pic%20all%20write%20010c/pic_doc/PULSOUT.htm (2 of 2)08.08.2003 03:52:52
Plik z chomika:
fred1144
Inne pliki z tego folderu:
Whats a Microcontroller.pdf
(5198 KB)
ThePicBook.rar
(1958 KB)
-Electronics- (ebook - PDF) - PICBasic for PIC Microcontroll.rar
(1118 KB)
BASIC for PIC microcontrollers.doc
(1052 KB)
80051c.pdf
(59 KB)
Inne foldery tego chomika:
#JAL stuff
_PIC
Alti-Barométer
Curs Microcontrolere
Despre Eprom-uri si Microcontrolare - complet
Zgłoś jeśli
naruszono regulamin