Texas Instruments MSC1210 User Manual

Page 130

Advertising
background image

PWM Generator

11-6

Figure 11−5. Timing Diagram of a PWM Waveform

In the timing diagram of a PWM waveform in Figure 11−5, the waveform is low
for 2 ticks and high for 4 ticks. Thus, the value of PWM Period = 5 (6 ticks minus
1) and PWM Duty = 1 (2 ticks minus 1). Assuming the PPOL (PWMCON.5) bit
is set, the actual length of a tick is defined by the value of USEC, or equal to
the period of CLK.

Configuring the PWM generator requires that the PWM Period and PWM Duty
registers be set. Both of these registers are set using the PWMLOW and
PWMHI SFRs; whether the program writes to PWM Period or PWM Duty is
configured by first clearing or setting PWMCON.4. When PWMSEL is clear
any subsequent write to PWMLOW/HI will write to the PWM Duty register.
When PWMCON.4 is set, any subsequent write to PWMLOW/HI will write to
the PWM Period register. PWMLOW and PWMHI can be treated as one 16-bit
register because they are adjacent SFRs.

Thus, the general process for configuring the PWM generator is as follows:

1) Configure PWMCON so that PWM mode is selected, PWMCON[2:0] = 001.

2) Set PWMCON.4 to select the PWM Duty register.

3) Write the PWM Duty − 1 value to PWMLOW and PWMHI. In the above

example, PWMLOW/HI is written with the value 1 because the off period
is 2 ticks long, and the value written to PWM Period is the period less 1.

4) Clear PWMCON.4 to indicate that the program will now write to PWM Peri-

od.

5) PWMCON.5 must be set to either 0 or 1. If clear, the PWM Duty value (set

in step 3) is the time the signal will be high. If it is set, the PWM Duty value
is the time the signal will be low. PWM Duty must be less than PWM Period
or the output will stay in the state defined by PWMCON.5

6) Write the PWM Period − 1 value to PWMLOW and PWMHI. The value is

the total number of USEC ticks of the period of the PWM. In the above ex-
ample, PWMLOW/HI is written with the value 5, because the total period
is 6 ticks long, and the value written to PWM Period is the period – 1.

Advertising