Chapter 9
16-bit Timer
IX - 34 16-bit Standard PWM Output (with Continuously Variable Duty)
9.6.2 Setup Example
Standard PWM Output Setup Example
Here is an example that, using Timer 7, the PWM output waveform with the 1/4 duty cycle and 122.1 Hz is output
from TM7IO output pin. HCLK (at f
HCLK
= 8 MHz) is selected as a clock source.
The setup procedure and its description are shown below
Figure:9.6.4 Output Waveform of TM7IO Output Pin
..
The PWM output at the initial state is "Low". It changes to "High" at the time the PWM opera-
tion is selected by setting TM7MD2.TM7PWM to "1".
..
Step Setting Register Description
1 Disable the timer counter TM7MD.TM7EN = 0 Disable the timer count operation.
2 Select the timer output pin TMIOEN1.TM7OEN = 1 Select the timer output pin.
[Chapter 7 I/O Port]
3 P0DIR.P0DIR4 = 1
4 Set the timer mode register TM7MD2.TM7PWM = 1 Select the PWM output.
5 TM7MD2.TM7BCR = 0 Select the TM7BC clear source.
6
TM7MD1.TM7CK1-0 = 00
TM7MD1.TM7PS1-0 = 00
Select HCLK as the count clock source.
7
Set the "High" period of PWM TM7PR1 = 0x3FFF Set the "High" period of PWM output.
Setup value: 65536 / 4 - 1 = 16383 (0x3FFF)
8 Enable the timer counter TM7MD1.TM7EN = 1 Enable the timer count operation.
TM7IO output
122.1 Hz