Rabbit MP3 PlayerA 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. SchematicThe 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. LCDThe 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:
ConstructionFor 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! SoftwareGetting MP3 Data From The NetThe 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 STA013The 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:
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 STA013Data 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. StatusWell, 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.75MBytesToo fast 1.30MBytes ComponentsHere is a list of components I used, their order codes and approximate prices.
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 ProjectYou 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