AN110
16-BIT PWM USING AN ON-CHIP TIMER
The example also configures the target board to
sample the PWM output using the on-chip ADC.
This DAC implementation may be used to evaluate
the C8051F220/1/6’s ADC.
Relevant Devices
This application note applies to the following
devices:
C8051F000, C8051F001, C8051F002,
C8051F005, C8051F006, C8051F007,
C8051F010, C8051F011, C8051F012, C8051F015,
C8051F016, C8051F017, C8051F220,
C8051F221, C8051F226, C8051F230,
C8051F231, and C8051F236.
Key Points
•
The C8051F2xx family SoC’s feature three on-
board 16-bit timers that can be used for PWM
generation. This example uses Timer 0 to pro-
duce the PWM wave which is output to a gen-
eral-purpose port pin.
Note: the C8051F0xx devices have an on-chip
PCA which may be more suitable for PWM gener-
ation. See AN007 for more information.
•
•
The C8051F2xx family of SoC’s have an 8-bit
ADC that is used in the provided example to
sample the output of the PWM DAC.
The C8051F226-TB target board features a
low-pass filter that can readily be used for the
PWM DAC and configured to be sampled by
the on-chip ADC without soldering or adding
extra wiring. Target board use is assumed in the
provided example.
Introduction
This document describes how to implement a 16-
bit pulse width modulator (PWM) digital-to-analog
converter (DAC). The PWM consists of two parts:
1. A timer to produce a PWM waveform of a
given period and specified duty cycle.
Generating the PWM Input
Waveform
2. A low-pass filter to convert the PWM wave to
an analog voltage level output.
Pulse-Width Modulation (PWM) is a method of
encoding data by varying the width of a pulse or
changing the duty cycle of a periodic waveform.
Adjusting the duty cycle of this waveform, we con-
trol the voltage output from the low-pass filter. This
can be thought of as a type of digital-to-analog con-
vertor (DAC). In this example, we use Timer 0 to
time the toggling of a general purpose port pin to
create the PWM waveform.
A PWM coupled with a low-pass filter can be used
as a simple, low cost digital to analog converter
(DAC). This output can be used to drive to a volt-
age controlled device, or used in a feedback control
system where an analog-to-digital convertor
(ADC) is used to sample a controlled parameter.
PWM’s are often used in motor control applica-
tions.
Configuring Timer 0
Implementation software and hardware is dis-
cussed in this application note. An example of a
PWM using an on-chip timer and a low-pass filter
on the C8051F226-TB target board is provided.
In order to create a PWM wave with a user speci-
fied duty cycle, we use Timer 0 in 16-bit counter/
timer mode. To do so, we configure the Timer
Rev. 1.2 12/03
Copyright © 2003 by Silicon Laboratories
AN110-DS12