SN8P1700
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 115
Revision 1.93
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
FT0IEN
; To disable T0 interrupt service
B0BCLR
FT0ENB
; To disable T0 timer
MOV
A,#20H
;
B0MOV
T0M,A
; To set T0 clock = fcpu / 64
MOV
A,#74H
B0MOV
T0C,A
; To set T0C initial value = 74H (To set T0 interval = 10 ms)
B0BSET
FT0IEN
; To enable T0 interrupt service
B0BCLR
FT0IRQ
; To clear T0 interrupt request
B0BSET
FT0ENB
; To enable T0 timer
Example: T0 interrupt service routine.
ORG
8
; Interrupt vector
JMP
INT_SERVICE
INT_SERVICE:
B0XCH
A, ACCBUF
; B0XCH doesn’t change C, Z flag
PUSH
;
Push
B0BTS1
FT0IRQ
; Check T0IRQ
JMP
EXIT_INT
; T0IRQ = 0, exit interrupt vector
B0BCLR
FT0IRQ
; Reset T0IRQ
MOV
A,#74H
; Reload T0C
B0MOV
T0C,A
.
.
; T0 interrupt service routine
. .
JMP
EXIT_INT
; End of T0 interrupt service routine and exit interrupt vector
. .
. .
EXIT_INT:
B0XCH
A,
ACCBUF
PUSH
;
Push
RETI
; Exit interrupt vector