SN8P1829
8-Bit MCU build-in 12-bit ADC + PGIA + Charge-pump Reg 128 dots LCD driver
SONiX TECHNOLOGY CO., LTD
Page 73
Version 1.0
TC1 TIMER COUNTER OPERATION SEQUENCE
The TC1 timer’s sequence of operation can be following.
Set the TC1C initial value to setup the interval time.
Set the TC1ENB to be “1” to enable TC1 timer counter.
TC1C is incremented by one with each clock pulse which frequency is corresponding to TC1M selection.
TC1C overflows if TC1C from FFH to 00H.
When TC1C overflow occurs, the TC1IRQ flag is set to be “1” by hardware.
Execute the interrupt service routine.
Users reset the TC1C value and resume the TC1 timer operation.
Example: Setup the TC1M and TC1C without auto-reload function.(TC1_Counter=8-bit, TC1X8=0)
B0BCLR
FTC1X8
;
B0BCLR
FTC1IEN
; To disable TC1 interrupt service
B0BCLR
FTC1ENB
; To disable TC1 timer
MOV
A,#20H
;
B0MOV
TC1M,A
; To set TC1 clock = Fcpu / 64
MOV
A,#74H
; To set TC1C initial value = 74H
B0MOV
TC1C,A
;(To
set
TC1 interval = 10 ms)
B0BSET
FTC1IEN
; To enable TC1 interrupt service
B0BCLR
FTC1IRQ
; To clear TC1 interrupt request
B0BSET
FTC1ENB
; To enable TC1 timer
Example: Setup the TC1M and TC1C with auto-reload function. (TC1_Counter=8-bit, TC1X8=0)
B0BCLR
FTC1X8
; To select TC1=Fcpu/2 as clock source
B0BCLR
FTC1IEN
; To disable TC1 interrupt service
B0BCLR
FTC1ENB
; To disable TC1 timer
MOV
A,#20H
;
B0MOV
TC1M,A
; To set TC1 clock = Fcpu / 64
MOV
A,#74H
; To set TC1C initial value = 74H
B0MOV
TC1C,A
; (To set TC1 interval = 10 ms)
B0MOV
TC1R,A
; To set TC1R auto-reload register
B0BSET
FTC1IEN
; To enable TC1 interrupt service
B0BCLR
FTC1IRQ
; To clear TC1 interrupt request
B0BSET
FTC1ENB
; To enable TC1 timer
B0BSET
ALOAD1
; To enable TC1 auto-reload function.