SN8P1600
8-bit micro-controller
TC0 TIMER OPERATION SEQUENCE
The TC0 timer’s sequence of operation may be as following.
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
Set the TC0C initial value to setup the interval time.
Set the TC0ENB to be “1” to enable TC0 timer.
TC0C is incremented by one after each clock pulse corresponding to TC0M selection.
TC0C overflow if 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.
B0BCLR
B0BCLR
MOV
FTC0IEN
FTC0ENB
A,#20H
; To disable TC0 interrupt service
; To disable TC0 timer
;
B0MOV
MOV
B0MOV
TC0M,A
A,#74H
TC0C,A
; To set TC0 clock = fcpu / 64
; To set TC0C initial value = 74H
;(To set TC0 interval = 10 ms)
B0BSET
B0BCLR
B0BSET
FTC0IEN
FTC0IRQ
FTC0ENB
; To enable TC0 interrupt service
; To clear TC0 interrupt request
; To enable TC0 timer
ꢃ
Example: TC0 interrupt service routine.
ORG
JMP
8
; Interrupt vector
INT_SERVICE
INT_SERVICE:
B0XCH
B0MOV
B0MOV
A, ACCBUF
A, PFLAG
PFLAGBUF, A
; B0xch instruction do not change C,Z flag
B0BTS1
JMP
FTC0IRQ
EXIT_INT
; Check TC0IRQ
; TC0IRQ = 0, exit interrupt vector
B0BCLR
MOV
B0MOV
.
FTC0IRQ
A,#74H
TC0C,A
.
; Reset TC0IRQ
; Reload TC0C
; TC0 interrupt service routine
.
.
JMP
EXIT_INT
; End of TC0 interrupt service routine and exit interrupt
vector
.
.
.
.
EXIT_INT:
B0MOV
B0MOV
B0XCH
A, PFLAGBUF
PFLAG, A
A, ACCBUF
; Restore ACC value.
; Exit interrupt vector
RETI
SONiX TECHNOLOGY CO., LTD
Page 55
Revision 1.94