SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 73
V1.4
8.3.5 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 overflow if TC1C from FFH to 00H.
¾
When TC1C overflow occur, 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.
B0BCLR
FTC1IEN
; To disable TC1 interrupt service
B0BCLR
FTC1ENB
; To disable TC1 timer
B0BCLR
FTC1X8
;
MOV
A,#00H
;
B0MOV
TC1M,A
; To set TC1 clock = fcpu / 256
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.
B0BCLR
FTC1IEN
; To disable TC1 interrupt service
B0BCLR
FTC1ENB
; To disable TC1 timer
B0BCLR
FTC1X8
;
MOV
A,#00H
;
B0MOV
TC1M,A
; To set TC1 clock = fcpu / 256
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.