8-BIT TIMER A/B S3C8245/P8245/C8249/P8249
11-10
F PROGRAMMING TIP — To generate a one pulse signal through P3.0
This example sets Timer B to the one shot mode, sets the oscillation frequency as the Timer B clock source, and
TBDATAH and TBDATAL to make a 40 µs width pulse. The program parameters are:
40
µ
s
Timer B is used in one shot mode
Oscillation frequency is 4 MHz (1 clock = 0.25 µs)
TBDATAH = 40 µs / 0.25 µs = 160, TBDATAL = 1
Set P3.0 to TBPWM mode
ORG 0100H ;Reset address
START DI
LD TBDATAH,# (160-2) ;Set 40 µs
LD TBDATAL,# 1 ;Set any value except 00H
LD TBCON,#00000001B ;Clock Source fOSC
;Disable Timer B interrupt.
;Select one shot mode for Timer B.
; Stop Timer B operation.
; Set Timer B output flip-flop (TBOF) high
LD P3CONL, #02H ;Set P3.0 to TBPWM mode.
Pulse_out: LD TBCON,#00000101B ;Start Timer B 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.