English
Language : 

SN8P2602B Datasheet, PDF (80/95 Pages) SONiX Technology Company – 8-Bit Micro-Controller
SN8P2602B
8-Bit Micro-Controller
8.3.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
or
B0BSET
FTC0CKS
; Select TC0 internal clock source.
; Select TC0 external clock source.
) Set TC0 timer auto-load mode.
B0BCLR
FALOAD0
; Enable TC0 auto reload function.
or
B0BSET
FALOAD0
; 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
A,#7FH
; TC0C and TC0R value is decided by TC0 mode.
B0MOV
TC0C,A
; Set TC0C value.
B0MOV
TC0R,A
; Set TC0R value under auto reload mode or PWM mode.
; In PWM mode, set PWM cycle.
B0BCLR
B0BCLR
or
B0BCLR
B0BSET
or
B0BSET
B0BCLR
or
B0BSET
B0BSET
FALOAD0
FTC0OUT
FALOAD0
FTC0OUT
FALOAD0
FTC0OUT
FALOAD0
FTC0OUT
; ALOAD0, TC0OUT = 00, PWM cycle boundary is
; 0~255.
; ALOAD0, TC0OUT = 01, PWM cycle boundary is
; 0~63.
; ALOAD0, TC0OUT = 10, PWM cycle boundary is
; 0~31.
; ALOAD0, TC0OUT = 11, PWM cycle boundary is
; 0~15.
SONiX TECHNOLOGY CO., LTD
Page 80
Preliminary Version 0.4