Rabbit MP3 Player


Rabbit MP3 Player

A lot of people seem to have a go at making an MP3 player, so here is my first attempt. The idea is to build a streaming Internet radio player.

After a bit of looking around, I decided that the STA013 MP3 decoder chip was the one to use. It doesn't seem to complicated and is available from RS. The data sheet is availble from the ST web site. Next, I had to decide on a D to A converter. The example ST give uses the CS4331 and there are other examples on the web using the CS4334. I couldn't find either of these easily available, so I plumped for the CS4330, again available from RS.

Schematic

The schematic is too big to include here as an image, but it is included in the download at the bottom of this page.

Basically, the circuit is the sample given by ST, with a few minor changes for the DAC. I have also included an LCD - 20 x 4 lines, to display such things as track name etc, though I now think that this is too small be be that useful.

LCD

The LCD I used is a DEM 20485 SYH-LY/V, available from Maplin. It makes use of the HD44780 and HD44100 (or OKI/Samsung equivalent) driver chip protocols. Maplin don't supply any data with this LCD, so here is the pin out:

PinFunction
1Ground
2Power supply for logic (+5V)
3LCD drive voltage
4Register select. 1 = data, 0 = control
5Read/Write. 1 = read, 0 = write
6Enable
7Data Bit 0
8Data Bit 1
9Data Bit 2
10Data Bit 3
11Data Bit 4
12Data Bit 5
13Data Bit 6
14Data Bit 7
15Backlight ground
16Backlight power +5V

Construction

For the initial prototype, I constructed the circuit on breadboard. It has to be said that this introduced a few problems of its own - like poor connections and odd loadings. However, I managed to get it to work, but did have to play around with the oscillator circuit to get it to run correctly.

The first problem is that both the STA013 and CS4330 are surface mount devices - not good for breadboard. Adapter boards are available, but are not cheap. I got some from RS.

Here is a picture of the breadboard with everything except the DAC connected. You will see that by this stage I'd managed to get the LCD working.

Once the DAC was connected up I started on the tricky task of getting it to play music!

Software

Getting MP3 Data From The Net

The RCM3200 comes with a TCP/IP stack - which is handy. When I started I wasn't too sure how Internet radio was broadcast. After a little research, it came clear that most Internet radio stations use ShoutCast. If you take a look at the ShoutCast site, you will find a lack of documentation. Searching the Internet turned up very little. As it turns out there is not that much to know, it is very simple. I have collated all the information I found, and put it all on this page.

Configuring The STA013

The STA013 does require quite a bit of configuring. For a start there is a whole load of data that you must donwload to the device before it'll do anything. But, before we can do that, we need to be able to talk to it.

Configuration and control is done via an I2C interface. Fairly simple, and a library is supplied with Dynamic C. The first thing I tried was to read back the device ID. This is held at location 1 and is always 0xAC. Having got that working, I knew that my I2C communications were fine, and I could move onto configuring the device. The first thing that must be done is to download the 2000 or so configuration words - don't worry, these are supplied by ST (and included in my download). After this, we must configure the device for our application. This is where we set things like our clock frequency and the interface to the DAC. The datasheet includes a number of values for different clocks, and describes the difference data formats for the DAC. In my case, using the CS4330 and a 14.7456MHz clock, the following are used:

LocationDataMeaning
841PCM Divider
851PCM Configuration
70PLL Control
612PLL Control
113Reserved ??
9715MFSDF
8016MFSDF 441
10185PLL Faction (H)
824PLL Fraction 441 (H)
10085PLL Faction (L)
810PLL Fraction 441 (L)
5161PLL Control
244Data Request Enable

Most of this data is taken directly from the data sheet. Address 85 sets the format for the data to the DAC, if you use something other than the CS4330, then you will probably need to change this. Address 24 configures the data request signal. I have set this so that the STA013 tells me when it is able to accept data.

Now that the STA013 is configured, we need to start passing it data.

Sending MP3 Data To The STA013

Data is sent to the STA013 over a different interface, SPI. As luck would have it, an SPI library is supplied with Dynamic C. This library makes use of hardware inside the Rabbit chip to convert parallel data into a serial bit stream. Here is a picture of what this stream looks like, as you can see it is possible to send data at a decent speed.

The top trace is data, and the bottom is the clock.

That's almost it. The last thing that needs to be done is to make sure that the STA013 doesn't run out of data. Bt we must also not send data to it too fast. In the configuration table above, the STA013 was configured to indicate when it is able to accept data, so data may only be sent during this time. When the STA013 is uable to accept data the Rabbit can get more data from the network, update the LCD and do any other small tasks that are requried.

Status

Well, it just about works. I'm not happy with the LCD, I think it's too small. I also have trouble with the oscillator circuit. I've decided to get a board made up. I will be sticking with the current LCD while I develop more software for it. My board layout looks like this:

It is only a little larger than the Rabbit module, but doesn't include any power supply - so must be supplied with 3.3V and 5V. For more information about my MP3 PCB, click here

If you have tried to make one, and are getting strange noises, don't worry I got some very odd sounds. Here are a couple QuickTime clips of an early build. The trace on the 'scope is the audio out. The first is a very early sample when I had the format of the data going to the DAC wrong, the second is almost working just running rather too fast.

Strange noises 1.75MBytes
Too fast 1.30MBytes

Components

Here is a list of components I used, their order codes and approximate prices.

ComponentMaplin Order CodeQuantityPrice Each
5mm Green LEDWL28F2£0.10
4x20 LCD ModuleN30AZ1£24.99
1M ResistorM1M1£0.07
560Ohm ResistorM560R2£0.07
4.7Ohm ResistorM4R72£0.07
270k ResistorM270K2£0.07
330Ohm ResistorM330R2£0.07
4k7 ResistorM4K76£0.07
470uH ChokeWH451£0.17
14.7456MHz CrystalRR881£0.49
33nF CapWW252£0.15
0.1uF CapRA495£0.07
1nF CapDT92A1£0.07
22pF CapRA23M2£0.07
470pF CapRA38R1£0.07
4.7nF CapWW26D1£0.17
3.5mm Jack SocketFK20W1£0.99

ComponentRS Order CodeQuantityPrice Each
STA013380-27141£26.82
CS4330207-25021£6.93
SM Adapter (5 pack)158-29791£40.78

Yes, I know the surface mount adapter is very expensive. I had a lot of trouble finding one, if you find somewhere that sells them in packs of one at a decent price - please let me know.

You will need various headers and cables as well.

Download Project

You can download the complete project in one zip file (94.7KBytes).

Please note that this zip file contains the files of the board, except for the board layout. The schamatic is what you'd need if building on breadboard. The software is also included.


Note:All projects on this site are "as is", with no guarantee offered or implied. While every effort has been made to ensure the correct operation of the projects, no responsibility is accepted for any loss, damage or charges incurred which may arise from the use of these projects.

© 2003-2008 James Battersby
Main Page | Mail the WebMaster