SN8P1829
8-Bit MCU build-in 12-bit ADC + PGIA + Charge-pump Reg 128 dots LCD driver
SONiX TECHNOLOGY CO., LTD
Page 76
Version 1.0
PWM FUNCTION DESCRIPTION
OVERVIEW
PWM function is generated by TC0/TC1 timer counter and output the PWM signal to PWM0OUT pin (P5.4)/
PWM1OUT pin (P5.3). When code option TC0/TC1_Counter= 8-bit, the 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. Table 7-4 listed the low-to-high ratio (duty) of the
PWM0/PWM1 output.
For example, TC0_Counter=8-bit, all PWM outputs remain inactive during the first 256 input clock signals. Then, when
the counter value (TC0C/TC1C) changes from FFH back to 00H, the PWM output is forced to high level. The pulse
width ratio (duty cycle) is defined by the contents of the reference register (TC0R/TC1R) and is programmed in
increments of 1:256. The 8-bit PWM data register TC0R/TC1R is write-only register. Different code option of
TC0_Counter/TC1_Counter will cause different PWM Duty, so user can generate different PWM output by selection
different TC0_Counter/TC1_Counter.
PWM output can be held at low level by continuously loading the reference register with 00H. Under PWM operating, to
change the PWM’s duty cycle is to modify the TC0R/TC1R.
TC0X8/TC1X8
PWM0 Frequency
PWM1 Frequency
0
F
OSC
/(2
10-TC0RATE
)/N F
OSC
/(2
10-TC1RATE
)/N
1
F
OSC
/(2
7-TC0RATE
) /N
F
OSC
/(2
7-TC1RATE
) /N
The value of N depend on code option TC0_Counter/TC1_Counter
TC0_Counter/TC1_Counter
N
PWM Duty Cycle
8-bit
256
0/256 ~ 255/256
6-bit
64
0/64 ~ 63/64
5-bit
32
0/32 ~ 31/32
4-bit
16
0/16 ~ 15/16
Table 8-1. The PWM Frequency Calculation Formula
TC0X8
TC1X8
TC0_Counter
TC1_Counter
TC0/TC1
Overflow boundary
PWM Duty Cycle
Max PWM Frequency
(F
OSC
= 4MHz)
Note
0
8-bit
FFh to 00h
0/256 ~ 255/256
1.953125K
Overflow per 256 count
0
6-bit
3Fh to 40h
0/64 ~ 63/64
7.8125K
Overflow per 64 count
0
5-bit
1Fh to 20h
0/32 ~ 31/32
15.625K
Overflow per 32 count
0
4-bit
0Fh to 10h
0/16 ~ 15/16
31.25K
Overflow per 16 count
1
8-bit
FFh to 00h
0/256 ~ 255/256
15.625
Overflow per 256 count
1
6-bit
3Fh to 40h
0/64 ~ 63/64
62.5K
Overflow per 64 count
1
5-bit
1Fh to 20h
0/32 ~ 31/32
125K
Overflow per 32 count
1
4-bit
0Fh to 10h
0/16 ~ 15/16
250K
Overflow per 16 count
Table 8-2. The Maximum PWM Frequency Example (TC0RATE/TC1RATE = 111)