Read the previous article in this series for the fundamentals of microcontroller audio. Learn about basic MSP430 connections and programming in the MSP430 primer. This week we'll use the tiny, inexpensive MSP430 microcontroller to play audio from a SD card.
Playing an audio file
In the previous project, I used the MSP430 pulse-width modulator (PWM) to generate simple tones. The PWM duty cycle changed the frequency, and thus tone, of the generated signal. The signal is cleaned by a simple audio filter, and amplified by powered PC speakers. Hear it in this video clip from the previous article:
Each value generates a different frequency. If we change the values about 8000 times a second (8KHz) we can reproduce telephone quality audio.
8 bit audio (each sample requires one byte) at 8KHz requires 8000 bytes of data per second. 16 bit audio, the quality associated with CD players and PCs, requires twice as much data per sample (16 bits or 2 bytes) -- 16 kilobytes/second.
With 2K of internal flash, the MSP430 can store about one-quarter second of audio. External memory is needed to store any meaningful amount of audio. There's no better source of cheap storage than flash memory chips. A raw flash memory chip would be a special order item, but you probably already have some flash memory -- SD cards! These cards are ubiquitous in digital cameras and low-end MP3 players.