Microchip Technology DM300019 Data Sheet
Demonstration Program Operation
© 2006 Microchip Technology Inc.
DS51584B-page 29
3.4.3
Digital-to-Analog Conversion
This program uses Digital Potentiometer MCP41010 on the dsPICDEM 80-Pin Starter
Development Board as a D/A converter to generate a sine-wave signal (audio tone) to
the LINE OUT pin. The digital potentiometer is driven by the output of the serial
peripheral interface SPI2 of the dsPIC30F6014A device, which receives its input from
the program.
The program retrieves HEX values from a table in data memory and delivers it to the
SPI. Thirty-two stored values cover the full range of the digital potentiometer. As the
analog output of the digital potentiometer passes through the MCP6022 Operational
Amplifier (configured as a low-pass filter) it results in a 400 Hz sine wave based on a
new table value every 125
Development Board as a D/A converter to generate a sine-wave signal (audio tone) to
the LINE OUT pin. The digital potentiometer is driven by the output of the serial
peripheral interface SPI2 of the dsPIC30F6014A device, which receives its input from
the program.
The program retrieves HEX values from a table in data memory and delivers it to the
SPI. Thirty-two stored values cover the full range of the digital potentiometer. As the
analog output of the digital potentiometer passes through the MCP6022 Operational
Amplifier (configured as a low-pass filter) it results in a 400 Hz sine wave based on a
new table value every 125
μsec covering all 32 table values. The sine wave is placed
on the LINE OUT pin of the development board.
Figure 3-3 illustrates the digital-to-analog conversion process. Switches S1 and S2 are
used to change the output frequency to 800 Hz and 1600 Hz, respectively, by skipping
over some of the table values.
Figure 3-3 illustrates the digital-to-analog conversion process. Switches S1 and S2 are
used to change the output frequency to 800 Hz and 1600 Hz, respectively, by skipping
over some of the table values.
FIGURE 3-3:
DIGITAL-TO-ANALOG CONVERSION PROGRAM FLOW
INIT SPI2
Set W4 = Value Pointed to by
W1 Using PSV
Transmit Contents of W4 to
SPI2
Yes
Set Reg W2 to Start of Tone Table
Set Reg W3 to End of Tone Table
Set Reg W1 = W2
Set Reg W3 to End of Tone Table
Set Reg W1 = W2
Has 150
μsec Interrupt
Occurred?
Set W1 = W1 + 2
S1 Pressed?
S2 Pressed?
Set W1 = W1 + 2
Set W1 = W1 + 4
Set W1 = W2
No
No
No
Yes
Yes
Yes
No
W1 > W3?
START