SN8F2250B Series
USB 2.0 Full-Speed 8-Bit Micro-Controller
8.4.6 TC0 TIMER OPERATION SEQUENCE
TC0 timer operation includes timer interrupt, event counter, TC0OUT and PWM. The sequence of setup TC0 timer is
as following.
)
)
Stop TC0 timer counting, disable TC0 interrupt function and clear TC0 interrupt request flag.
B0BCLR
B0BCLR
B0BCLR
FTC0ENB
FTC0IEN
FTC0IRQ
; TC0 timer, TC0OUT and PWM stop.
; TC0 interrupt function is disabled.
; TC0 interrupt request flag is cleared.
)
Set TC0 timer rate. (Besides event counter mode.)
MOV
B0MOV
A, #0xxx0000b
TC0M,A
;The TC0 rate control bits exist in bit4~bit6 of TC0M. The
; value is from x000xxxxb~x111xxxxb.
; TC0 interrupt function is disabled.
)
Set TC0 timer clock source.
; Select TC0 internal / external clock source.
B0BCLR
FTC0CKS
; Select TC0 internal clock source.
; Select TC0 external clock source.
or
B0BSET
FTC0CKS
)
or
)
Set TC0 timer auto-load mode.
B0BCLR
B0BSET
FALOAD0
FALOAD0
; Enable TC0 auto reload function.
; Disable TC0 auto reload function.
Set TC0 interrupt interval time, TC0OUT (Buzzer) frequency or PWM duty cycle.
; Set TC0 interrupt interval time, TC0OUT (Buzzer) frequency or PWM duty.
MOV
B0MOV
B0MOV
A,#7FH
TC0C,A
TC0R,A
; TC0C and TC0R value is decided by TC0 mode.
; Set TC0C value.
; Set TC0R value under auto reload mode or PWM mode.
; In PWM mode, set PWM cycle.
B0BCLR
B0BCLR
FALOAD0
FTC0OUT
; ALOAD0, TC0OUT = 00, PWM cycle boundary is
; 0~255.
or
B0BCLR
B0BSET
or
FALOAD0
FTC0OUT
; ALOAD0, TC0OUT = 01, PWM cycle boundary is
; 0~63.
B0BSET
B0BCLR
or
FALOAD0
FTC0OUT
; ALOAD0, TC0OUT = 10, PWM cycle boundary is
; 0~31.
B0BSET
B0BSET
FALOAD0
FTC0OUT
; ALOAD0, TC0OUT = 11, PWM cycle boundary is
; 0~15.
)
Set TC0 timer function mode.
B0BSET
B0BSET
B0BSET
FTC0IEN
; Enable TC0 interrupt function.
; Enable TC0OUT (Buzzer) function.
; Enable PWM function.
or
or
FTC0OUT
FPWM0OUT
)
Enable TC0 timer.
B0BSET
FTC0ENB
; Enable TC0 timer.
SONiX TECHNOLOGY CO., LTD
Page 87
Version 1.1