SN8P1700
8-bit micro-controller build-in 12-bit ADC
T0 BASIC TIMER OPERATION SEQUENCE
The T0 basic timer’s sequence of operation can be following.
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
ꢂ
Set the T0C initial value to setup the interval time.
Set the T0ENB to be “1” to enable T0 basic timer.
T0C is incremented by one with each clock pulse which frequency is corresponding to T0M selection.
T0C overflow when T0C from FFH to 00H.
When T0C overflow occur, the T0IRQ flag is set to be “1” by hardware.
Execute the interrupt service routine.
Users reset the T0C value and resume the T0 timer operation.
ꢃExample: Setup the T0M and T0C.
B0BCLR
B0BCLR
MOV
B0MOV
MOV
B0MOV
B0BSET
B0BCLR
B0BSET
FT0IEN
; To disable T0 interrupt service
; To disable T0 timer
;
FT0ENB
A,#20H
T0M,A
A,#74H
T0C,A
FT0IEN
FT0IRQ
FT0ENB
; To set T0 clock = fcpu / 64
; To set T0C initial value = 74H (To set T0 interval = 10 ms)
; To enable T0 interrupt service
; To clear T0 interrupt request
; To enable T0 timer
ꢃExample: T0 interrupt service routine.
ORG
JMP
8
; Interrupt vector
INT_SERVICE
INT_SERVICE:
B0XCH
PUSH
A, ACCBUF
; B0XCH doesn’t change C, Z flag
; Push
B0BTS1
JMP
FT0IRQ
EXIT_INT
; Check T0IRQ
; T0IRQ = 0, exit interrupt vector
B0BCLR
MOV
FT0IRQ
A,#74H
; Reset T0IRQ
; Reload T0C
B0MOV
T0C,A
.
.
; T0 interrupt service routine
.
.
JMP
EXIT_INT
; End of T0 interrupt service routine and exit interrupt vector
.
.
.
.
EXIT_INT:
POP
; Pop
B0XCH
A, ACCBUF
;Restore ACC value
RETI
; Exit interrupt vector
SONiX TECHNOLOGY CO., LTD
Page 71
Revision 1.94