SN8P1700
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 120
Revision 1.93
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,#20H
;
B0MOV
TC0M,A
; To set TC0 clock = fcpu / 64
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,#20H
;
B0MOV
TC0M,A
; To set TC0 clock = fcpu / 64
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.