SN8P2714X_2715
8-bit micro-controller build-in 12-bit ADC
SONiX TECHNOLOGY CO., LTD
Page 76
V1.4
8.4 PWM FUNCTION DESCRIPTION
8.4.1 OVERVIEW
PWM function is generated by TC0/TC1 timer counter and output the PWM signal to PWM0OUT pin (P5.4)/
PWM1OUT pin (P5.3). The 8-bit counter counts modulus 256, from 0-255, inclusive. The value of the 8-bit counter is
compared to the contents of the reference register TC0R/TC1R. When the reference register value (TC0R/TC1R) is
equal to the counter value TC0C/TC1C, the PWM output goes low. When the counter reaches zero, the PWM output is
forced high.
Initial PWM output level is low until the counter value cross boundary (e.g. TC0C changes from FFH back to 00H), the
PWM outputs are forced to high level. The pulse width ratio (duty cycle) is defined by TC0R/TC1R registers and the
overflow boundary is defined by ALOAD0/ALOAD1 and TC0OUT/TC1OUT bits. PWM output can be held at low level
by continuously loading the TC0R/TC1R with 00H. By continuously loading the TC0R with boundary value (e.g. FFH),
you can hold the PWM output to high level, except for the last pulse of the clock source, which sends the output low.
PWM0OUT = 1, TC0X8=0
ALOAD0
ALOAD1
TC0OUT
TC1OUT
TC0 Overflow boundary
TC1 Overflow boundary
PWM duty range
Max PWM
Frequency
(Fcpu = 4M)
Note
0
0
FFh to 00h
0/256 ~ 255/256
7.8125K
Overflow per 256 count
0
1
3Fh to 40h
0/64 ~ 63/64
31.25K
Overflow per 64 count
1
0
1Fh to 20h
0/32 ~ 31/32
62.5K
Overflow per 32 count
1
1
0Fh to 10h
0/16 ~ 15/16
125K
Overflow per 16 count
ALOAD0
ALOAD1
TC0OUT
TC1OUT
TC0R
TC1R
PWM Duty Range
0
0
00000000 to 11111111
0/256 to 255/256
0
1
XX000000 to XX111111
0/64 to 63/64
1
0
XXX00000 to XXX11111
0/32 to 31/32
1
1
XXXX0000 to XXXX1111
0/16 to 15/16
Table 8-2. The PWM Duty Cycle Table
NOTE: If PWM0OUT or TC0OUT is enabled, P5.4 mode will be forced as output mode automatically.
When PWM0OUT or TC0OUT is disabled, P5.4 mode will be defined by P54M bit.
Figure 8-5 The Output of PWM with different TC0R/TC1R.
TC0/TC1 Clock
TC0R/TC1R = 00H
Low
High
Low
Low
High
TC0R/TC1R = 01H
TC0R/TC1R = 80H
TC0R/TC1R = FFH
Low
High
0
1
128
..... 254 255
.....
0
1
128
..... 254 255
.....
TC0/TC1 Clock
TC0R/TC1R = 00H
Low
High
Low
Low
High
TC0R/TC1R = 01H
TC0R/TC1R = 80H
TC0R/TC1R = FFH
Low
High
Low
High
0
1
128
..... 254 255
.....
0
1
128
..... 254 255
.....
0
1
128
..... 254 255
.....
.....
0
1
128
..... 254 255
.....
.....