SN8P2318 Series
C-type LCD, RFC 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 96
Version 1.5
8.4.9 T1 TIMER OPERATION EXAMPLE
T1 TIMER CONFIGURATION:
; Reset T1 timer.
MOV
A, #0x00
; Clear T1M register.
B0MOV
T1M, A
; Set T1 clock rate.
MOV
A, #0
nnn
0000b
; T1rate[2:0] bits.
B0MOV
T1M, A
; Set T1CH, T1CL registers for T1 Interval time.
MOV
A, #
value1
; Set high byte first.
B0MOV
T1CH, A
MOV
A, #
value2
; Set low byte.
B0MOV
T1CL, A
; Clear T1IRQ
B0BCLR
FT1IRQ
; Enable T1 timer and interrupt function.
B0BSET
FT1IEN
; Enable T1 interrupt function.
B0BSET
FT1ENB
; Enable T1 timer.
T1 CAPTURE TIMER FOR SINGLE CYCLE MEASUREMENT CONFIGURATION:
; Reset T1 timer.
MOV
A, #0x00
; Clear T1M register.
B0MOV
T1M, A
; Set T1 clock rate, select input source, and select/enable T1 capture timer.
MOV
A, #0
nnnm
000b
; “nnn” is T1rate[2:0] for T1 clock rate selection.
B0MOV
T1M, A
; “m” is T1 clock source control bit.
MOV
A, #000000
mm
b
; “mm” is CPTG[1:0] for T1 capture timer function selection.
B0MOV
T1CKSM, A
; CPTG[1:0] = 01b, high pulse width measurement.
; CPTG[1:0] = 10b, low pulse width measurement.
; CPTG[1:0] = 11b, cycle measurement.
; Clear T1CH, T1CL.
CLR
T1CH
; Clear high byte first.
CLR
T1CL
; Clear low byte.
; Clear T1IRQ
B0BCLR
FT1IRQ
; Enable T1 timer, interrupt function and T1 capture timer function.
B0BSET
FT1IEN
; Enable T1 interrupt function.
B0BSET
FT1ENB
; Enable T1 timer.
; Set capture timer start bit.
B0BSET
FCPTStart