SN8P2711A
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 97
Version 0.1
8.3.7 TC1 TIMER OPERATION SEQUENCE
TC1 timer operation includes timer interrupt, event counter, TC1OUT and PWM. The sequence of setup TC1 timer is
as following.
)
Stop TC1 timer counting, disable TC1 interrupt function and clear TC1 interrupt request flag.
B0BCLR
FTC1ENB
; TC1 timer, TC1OUT and PWM stop.
B0BCLR
FTC1IEN
; TC1 interrupt function is disabled.
B0BCLR
FTC1IRQ
; TC1 interrupt request flag is cleared.
)
Set TC1 timer rate. (Besides event counter mode.)
MOV
A, #0xxx0000b
;The TC1 rate control bits exist in bit4~bit6 of TC1M. The
; value is from x000xxxxb~x111xxxxb.
B0MOV
TC1M,A
; TC1 timer is disabled.
)
Set TC1 timer clock source.
; Select TC1 internal / external clock source.
B0BCLR
FTC1CKS
; Select TC1 internal clock source.
or
B0BSET
FTC1CKS
; Select TC1 external clock source.
; Select TC1 Fcpu / Fosc internal clock source .
B0BCLR
FTC1X8
; Select TC1 Fcpu internal clock source.
or
B0BSET
FTC1X8
; Select TC1 Fosc internal clock source.
Note: TC1X8 is useless in TC1 external clock source mode.
)
Set TC1 timer auto-load mode.
B0BCLR
FALOAD1
; Enable TC1 auto reload function.
or
B0BSET
FALOAD1
; Disable TC1 auto reload function.
)
Set TC1 interrupt interval time, TC1OUT (Buzzer) frequency or PWM duty cycle.
; Set TC1 interrupt interval time, TC1OUT (Buzzer) frequency or PWM duty.
MOV
A,#7FH
; TC1C and TC1R value is decided by TC1 mode.
B0MOV
TC1C,A
; Set TC1C value.
B0MOV
TC1R,A
; Set TC1R value under auto reload mode or PWM mode.
; In PWM mode, set PWM cycle.
B0BCLR
FALOAD1
; ALOAD1, TC1OUT = 00, PWM cycle boundary is 0~255.
B0BCLR FTC1OUT
or
B0BCLR
FALOAD1
; ALOAD1, TC1OUT = 01, PWM cycle boundary is 0~63.
B0BSET FTC1OUT
or
B0BSET
FALOAD1
; ALOAD1, TC1OUT = 10, PWM cycle boundary is 0~31.
B0BCLR FTC1OUT
or
B0BSET
FALOAD1
; ALOAD1, TC1OUT = 11, PWM cycle boundary is 0~15.
B0BSET FTC1OUT