Preliminary
SN8P1702A/SN8P1703A
8-bit micro-controller build-in 12-bit ADC
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. Following table 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
Fosc/(210-TC0RATE)/N
Fosc/(27-TC0RATE) /N
PWM1 Frequency
Fosc/(210-TC1RATE)/N
Fosc/(27-TC1RATE) /N
0
1
The value of N depend on code option TC0_Counter/TC1_Counter
TC0_Counter/TC1_Counter
N
256
64
32
16
PWM Duty Cycle
0/256 ~ 255/256
0/64 ~ 63/64
8-bit
6-bit
5-bit
4-bit
0/32 ~ 31/32
0/16 ~ 15/16
Table 8-6. The PWM Frequency Calculation Formula
TC0 Overflow
TC0X8 TC0_Counter
TC1X8 TC1_Counter
boundary
TC1 Overflow
boundary
Max PWM Frequency
PWM Duty Cycle
Note
(Fosc = 4MHz)
0
0
0
0
1
1
1
1
8-bit
6-bit
5-bit
4-bit
8-bit
6-bit
5-bit
4-bit
FFh to 00h
3Fh to 40h
1Fh to 20h
0Fh to 10h
FFh to 00h
3Fh to 40h
1Fh to 20h
0Fh to 10h
0/256 ~ 255/256
0/64 ~ 63/64
0/32 ~ 31/32
0/16 ~ 15/16
0/256 ~ 255/256
0/64 ~ 63/64
0/32 ~ 31/32
0/16 ~ 15/16
1.953125K
7.8125K
15.625K
31.25K
15.625
62.5K
Overflow per 256 count
Overflow per 64 count
Overflow per 32 count
Overflow per 16 count
Overflow per 256 count
Overflow per 64 count
Overflow per 32 count
Overflow per 16 count
125K
250K
Table 8-7. The Maximum PWM Frequency Example (TC0RATE/TC1RATE = 111)
SONiX TECHNOLOGY CO., LTD
Page 75
Revision 0.5