SN8P275X Series
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 96
Version 0.7
)
Set TC0 timer function mode.
B0BSET
FTC0IEN
; Enable TC0 interrupt function.
or
B0BSET
FTC0OUT
; Enable TC0OUT (Buzzer) function.
or
B0BSET
FPWM0OUT
; Enable PWM function.
)
Enable TC0 timer.
B0BSET
FTC0ENB
; Enable TC0 timer.
8.3.7 TC0 TIMER NOTICE
When TC0C value changes from “0xFF” to not “0xFF”, TC0IRQ is set “1” whether TC0 is operating or not. If TC0IRQ =
0 and TC0C is changed by program, TC0IRQ might be set as TC0C is from “0xFF” to not “0xFF”. The condition makes
unexpected TC0 interrupt occurring.
¾
Example: TC0C = 0xFF and TC0IRQ = 0. TC0IRQ will set as “1” when TC0C is cleared by program (TC0C =
0).
MOV
A, #0
; Clear TC0C.
B0MOV
TC0C, A
; TC0IRQ changed from “0” to “1”.
B0BSET
FTC0IEN
; Enable TC0 interrupt function and system jumps to interrupt
; vector (ORG 8) at next cycle.
If TC0C changing in system operating duration is necessary, to disable TC0 interrupt function (TC0IEN = 0) before
changing TC0C value. The solution can avoid unexpected TC0 interrupt occurring and example is as following.
¾
Example: TC0C = 0xFF and TC0IRQ = 0. Clearing TC0C must be after TC0 interrupt disable.
B0BCLR
FTC0IEN
; Disable TC0 interrupt function.
MOV
A, #0
; Clear TC0C.
B0MOV
TC0C, A
; TC0IRQ changed from “0” to “1”.
B0BCLR
FTC0IRQ
; Clear TC0IRQ flag.
B0BSET
FTC0IEN
; Enable TC0 interrupt function.
…
…
Note: Disable TC0 interrupt function first, and load new TC0C value into TC0C buffer. This way can avoid
unexpected TC0 interrupt occurring.
Note: TC0C and TC0R can’t be set as 0xFF when TC0 timer operating in interrupt, buzzer output modes.
TC0C and TC0R available range is 0x00~0xFE. The problem doesn’t exist in pure PWM mode.