SN8P2604
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 76
Version 1.1
8.2.5 T0 TIMER NOTICE
When T0C.7 is from “1” to “0”, T0IRQ is set “1” whether T0 is operating or not. If T0IRQ = 0 and T0C is changed by
program, T0IRQ might be set as T0C.7 is from “1” to “0”. The condition makes unexpected T0 interrupt occurring.
Example: T0C = 0x80 (T0C.7 = 1) and T0IRQ = 0. T0IRQ will set as “1” when T0C is cleared by program
(T0C.7 = 0).
MOV
A, #0
; Clear T0C and T0C.7 is from “1” to “0”.
B0MOV
T0C, A
; T0IRQ changed from “0” to “1”.
B0BSET
FT0IEN
; Enable T0 interrupt function and system jumps to interrupt
; vector (ORG 8) at next cycle.
If T0C changing in system operating duration is necessary, to disable T0 interrupt function (T0IEN = 0) before changing
T0C value. The solution can avoid unexpected T0 interrupt occurring and example is as following.
Example: T0C = 0x80 and T0IRQ = 0. T0IRQ will change to “1” when T0C is cleared by program.
B0BCLR
FT0IEN
; Disable T0 interrupt function.
MOV
A, #0
; Clear T0C and T0C.7 is from “1” to “0”.
B0MOV
T0C, A
; T0IRQ changed from “0” to “1”.
B0BCLR
FT0IRQ
; Clear T0IRQ flag.
B0BSET
FT0IEN
; Enable T0 interrupt function.
…
…
Note: Disable T0 interrupt function first, and load new T0C value into T0C buffer. This way can avoid
unexpected T0 interrupt occurring.
Note: T0C doesn’t support read and modify write instructions as “B0ADD M,A . INCMS…”.