SIC63616-(Rev. 1.0) NO. P103
3240-0412
4.9.5 PWM mode (Timers 0-7)
Each timer can generate a PWM waveform. When using this function, write "1" to the PTSELx register to set
the timer to PWM mode.
The compare data register CDx0–CDx7 is provided for each timer to control the PWM waveform. In PWM
mode, the timer compares data between the down counter and the compare data register and outputs the
compare match signal if their contents are matched. At the same time a compare match interrupt occurs.
Furthermore, the timer output signal rises with the underflow signal and falls with the compare match
signal. As shown in Figure 4.9.5.1, the cycle and duty ratio of the output signal can be controlled using the
reload data register and the compare data register, respectively, to generate a PWM signal. Note, however,
the following condition must be met: RLD (reload data) > CD (compare data) and CD
≠
0. If RLD
≤
CD, the
output signal is fixed at "1" after the first underflow occurs and does not fall to "0".
The generated PWM signal can be output from an I/O port (P13) terminal (see Section 4.9.8).
Count clock
RLD register
CD register
Down-counter value
Compare match signal
Underflow signal
Timer output signal
Compare match interrupt
Underflow interrupt
Compare match signal
Underflow signal
Timer output signal
Underflow interrupt
7
6
7
0
6 5 4 3 2 1 0 7 6 5 4
CD register value
3 2 1 0 7 6 5 4 3 2 1
RLD register value + 1
PWM mode
Normal mode
Fig. 4.9.5.1 Generating PWM waveform