SN8P2318 Series
C-type LCD, RFC 8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 87
Version 1.5
The resolution of PWM is decided by TC0R. TC0R range is from 0x00~0xFF. If TC0R = 0x00, PWM
’s resolution is
1/256. If TC0R = 0x80, PWM
’s resolution is 1/128. TC0D controls the high pulse width of PWM for PWM’s duty. When
TC0C = TC0D, PWM output exchanges to low status. TC0D must be greater than TC0R, or the PWM signal keeps low
status. When PWM outputs, TC0IRQ still actives as TC0 overflows, and TC0 interrupt function actives as TC0IEN = 1.
But strongly recommend be careful to use PWM and TC0 timer together, and make sure both functions work well.
The PWM output pin is shared with GPIO and switch to output PWM signal as PWM0OUT=1 automatically. If
PWM0OUT bit is cleared to disable PWM, the output pin exchanges to last GPIO mode automatically. It easily to
implement carry signal on/off operation, not to control TC0ENB bit.
PWM Output
PWM0OUT=1. The pin exchanges to output
mode and outputs PWM signal automatically.
PWM0OUT=0. The pin exchanges
to last GPIO mode (output low).
PWM0OUT=1.
PWM0OUT=0.
PWM Output
PWM0OUT=1. The pin exchanges to output
mode and outputs PWM signal automatically.
PWM0OUT=0. The pin exchanges
to last GPIO mode (output high).
PWM0OUT=1.
PWM0OUT=0.
PWM Output
PWM0OUT=1. The pin exchanges to output
mode and outputs PWM signal automatically.
PWM0OUT=0. The pin exchanges
to last GPIO mode (input).
PWM0OUT=1.
PWM0OUT=0.
High impendence (floating)
8.3.9 TC0 TIMER OPERATION EXAMPLE
TC0 TIMER CONFIGURATION:
; Reset TC0 timer.
CLR
TC0M
; Clear TC0M register.
; Set TC0 clock source and TC0 rate.
MOV
A, #0
nnn
0
n
00b
B0MOV
TC0M, A
; Set TC0C and TC0R register for TC0 Interval time.
MOV
A, #
value
; TC0C must be equal to TC0R.
B0MOV
TC0C, A
B0MOV
TC0R, A
; Clear TC0IRQ
B0BCLR
FTC0IRQ
; Enable TC0 timer and interrupt function.
B0BSET
FTC0IEN
; Enable TC0 interrupt function.
B0BSET
FTC0ENB
; Enable TC0 timer.