RS Audio Codec

The audio codec board mounted on the RS Animatronic Lab Board

This page provides information and some examples for the use of the RS Audio Codec sub board, based on TI's TLV320 chip. This chip provides a high quality audio link out and in to the mbed with IO including: an amplified stereo headphone out, an stereo line out, a stereo line in and an pre-amped mono microphone input. Such a capable chip opens up a lot of options for high quality audio on mbed.

One can get this AudioCODEC board from RS Part number 754-1974

Hello World!

Using the WAVPlayer test exmaple, here are two example WAVs that the program will read from USB drive

Import program

00001 // This is all set up for the AudioCODEC board on the AnimatronicLAB board (RS Product Code 754-1965): Just plug a memory stick
00002 // with a wav file called test.wav on it (such as the one you can get from: 
00003 // and have a listen! Any 16bit PCM Wav files with channel*sample rate less than 48kHz should work.
00005 #include "mbed.h"
00006 #include "WavPlayer.h"
00007 #include "MSCFileSystem.h"
00009 MSCFileSystem msc("msc"); // Mount flash drive under the name "msc"
00010 WavPlayer player;
00012 int main() {
00013     FILE *fp = fopen("/msc/test.wav", "r");  // Open "out.txt" on the local file system for writing
00016     fclose(fp);
00017 }


The AudioCODEC board has an accompanying lab board AnimatronicLab :


If using a breadboard, the wiring is shown below.

AudioCODECmbed NXP LPC1768
SCLKp10 *2k2 Pull up required
SDINp9 *2k2 Pull up required

The library has been tested with 16 bit files at these rates: Mono/Stereo 11025Hz, Mono 44.1kHz and Mono 48kHz.

This program doesn't need a flash drive or any files:

Import programTLV320_Write_test

A test program for the TLV320, Generates some sine waves.

Other info

Both programs use the TLV320 library and the I2S library:

Import libraryI2S

A well tested I2S library where the send and recieve parts are seperate instances.

Import libraryTLV320

A fairly well tested TLV320 library for I2C configuration and control of the TI TLV320 part

A WAV library was written to make the process of playing wave files easier:

Import library

Public Member Functions

WavPlayer ()
Create a WavPlayer instance.
WavPlayer (FILE **fpp)
Create a WavPlayer instance.
void open (FILE **fpp)
Set the file to read out of.
int getConfig ()
Extract the header infomation, automatically called by open.
float play ()
Play the entire file.
float play (float time)
Play the file for a certain number of seconds.
float play (float start, float timefor)
Play the file for a certain number of seconds, from a certain start point.

All wikipages