SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 64
V1.4
8.2.5 TC0 TIMER COUNTER OPERATION SEQUENCE
The TC0 timer counter’s sequence of operation can be following.
¾
Set the TC0C initial value to setup the interval time.
¾
Set the TC0ENB to be “1” to enable TC0 timer counter.
¾
TC0C is incremented by one with each clock pulse which frequency is corresponding to T0M selection.
¾
TC0C overflow when TC0C from FFH to 00H.
¾
When TC0C overflow occur, the TC0IRQ flag is set to be “1” by hardware.
¾
Execute the interrupt service routine.
¾
Users reset the TC0C value and resume the TC0 timer operation.
Â
Example: Setup the TC0M and TC0C without auto-reload function.
B0BCLR
FTC0IEN
; To disable TC0 interrupt service
B0BCLR
FTC0ENB
; To disable TC0 timer
MOV
A,#00H
;
B0MOV
TC0M,A
; To set TC0 clock = fcpu / 256
MOV
A,#74H
; To set TC0C initial value = 74H
B0MOV
TC0C,A
;(To set TC0 interval = 10 ms)
B0BSET
FTC0IEN
; To enable TC0 interrupt service
B0BCLR
FTC0IRQ
; To clear TC0 interrupt request
B0BSET
FTC0ENB
; To enable TC0 timer
Â
Example: Setup the TC0M and TC0C with auto-reload function.
B0BCLR
FTC0IEN
; To disable TC0 interrupt service
B0BCLR
FTC0ENB
; To disable TC0 timer
MOV
A,#00H
;
B0MOV
TC0M,A
; To set TC0 clock = fcpu / 256
MOV
A,#74H
; To set TC0C initial value = 74H
B0MOV
TC0C,A
; (To set TC0 interval = 10 ms)
B0MOV
TC0R,A
; To set TC0R auto-reload register
B0BSET
FTC0IEN
; To enable TC0 interrupt service
B0BCLR
FTC0IRQ
; To clear TC0 interrupt request
B0BSET
FTC0ENB
; To enable TC0 timer
B0BSET
ALOAD0
; To enable TC0 auto-reload function.