Programming 32-bit Microcontrollers in C: Exploring the PIC32

Day 16: Musica, Maestro!

The Plan

Gone is the time when music was an analog thing and the home stereo took up an entire rack of expensive electronics. Starting with music CDs almost 20 years ago and continuing today with iPods and MP3 players, music is now stored and consumed in digital form. For consumer and embedded applications, audio is an available and inexpensive option to delight but also to communicate with the user.

In this lesson we will explore the possibility to produce audio signals using the Output Compare modules of the PIC32. In Pulse Width Modulation (PWM) mode, and in combination with a more or less sophisticated low-pass filters, the Output Compare modules can be used effectively as DACs to produce an analog output signal. By modulating the analog signal with frequencies that fall into the range recognized by the human ear, between approximately 20 Hz and 20kHz, we get sound!

Preparation

In addition to the usual software tools, including the MPLAB IDE, the MPLAB C32 compiler, and the MPLAB SIM simulator, this lesson will require the use of the Explorer 16 demonstration board, an In-Circuit Debugger of your choice, and a soldering iron and a few components you'll need ready at hand to expand the board capabilities using the prototyping area or a small expansion board. You can check on the companion Web site (www.exploringPIC32.com) for the availability of expansion boards that will help you with the experiments that follow.

The Exploration

The way a PWM signal works is pretty simple.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Audio Mixers and Consoles
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.