S3F80JB COUNTER A
12-7
PROGRAMMING TIP — To generate a one-pulse signal through P3.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 us
— 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 P3.1 C-MOS push-pull output and CAOF mode.
— 44 pin package
ORG 0100H ; Reset address
START: DI
•
•
LD CADATAH,# (160-2) ; Set 40 ms
LD CADATAL,# 1 ; Set any value except 00H
;
LD P3CON,#11110010B ; Set P3 to C-MOS push-pull output.
; Set P3.1 to REM output
;
LD CACON,#00000001B ; Clock Source → Fosc
; Disable Counter A interrupt.
; Select one shot mode for Counter A.
; Stop Counter A operation.
; Set Counter A Output Flip-Flop (CAOF) high
LD P3,#80H ; Set P3.7(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 ms is required
• ; before the falling edge of the pulse starts.
•