S3C80A5B
COUNTER A
12-7
F
PROGRAMMING TIP — To Generate a One Pulse Signal Through P2.1
This example sets Counter A to the one shot mode, sets the oscillation frequency as the Counter A clock source,
and CADATAH and CADATAL to make a 40
µ
s width pulse. The program parameters are:
40
µ
s
— Counter A is used in one shot mode
— Oscillation frequency is 4 MHz (1 clock = 0.25
µ
s)
— CADATAH = 40
µ
s / 0.25
µ
s = 160, CADATAL = 1
— Set P2.1 C-MOS push-pull output and CAOF mode.
ORG
0100H
; Reset address
START
DI
•
•
LD
CADATAH,# (160-2)
; Set 40
µ
s
LD
CADATAL,# 1
; Set any value except 00H
;
LD
P2CON,#10101010B
; Set P2 to C-MOS push-pull output.
; Set P2.1 to REM output
;
LD
CACON,#00000001B
; Clock Source
←
f
OSC
; Disable Counter A interrupt.
; Select one shot mode for Counter A.
; Stop Counter A operation.
; Set Counter A Output flip-flop (CAOF) high
LD
P2,#20H
; Set P2.5(Carrier On/Off) to high.
•
•
•
Pulse_out:
LD
CACON,#00000101B
; Start Counter A operation
; to make the pulse at this point.
•
; After the instruction is executed, 0.75
µ
s is required
•
; before the falling edge of the pulse starts.
•