Chapter 8
8-bit Timer
8-bit PWM Output VIII - 27
8.6.2 Setup Example
PWM Output Setup Example
The PWM output waveform with the 1/4 duty cycle and 19.53 kHz is output from TM0IO output pin of Timer 0.
The oscillation of SYSCLK/2 is 5 MHz.
The setup procedure and the description of each step are shown below.
Figure:8.6.4 Output Waveform of TM0IO Output Pin
Step Setting Register Description
1 Disable the timer counter TM0MD.TM0EN = 0 Disable the timer count operation.
2 Select the timer output pin TMIOEN0.TM0OEN = 1 Select the timer output pin.
[Chapter 7 I/O Port]
3 P0DIR.P0DIR5 = 1
4
Set the timer mode register TM0MD.TM0PWM = 1
TM0MD.TM0MOD = 0
TM0MD.TM0POP = 0
Select the PWM operation.
5 TM0MD.TM0CK1-0 = 01 Select the prescaler as the clock source.
6
Set the prescaler CK0MD.TM0PSC1-0 = X0
CK0MD.TM0BAS = 1
Select SYSCLK/2.
7
Set the "High" period of PWM TM0OC = 0x40 Set the "High" period of PWM output.
Setup value: 256/4 = 64 (0x40)
8 Enable the timer counter TM0MD.TM0EN = 1 Enable the timer count operation.
M0IO output
19.53 kHz