ATmega168 Mp3 Player

Introduction

Goal of this project is to construct a mp3 player with a microcontroller, MMC/SD memory card and a mp3 decoding chip. And do this as cheap as possible offcourse.
The microcontroller used is the ATmega88 running at 14.7456 MHz, it also contains a small test mp3. The mp3 data is fed to the USART unit that has been configured in a SPI master which is in turn connected to the STA013 mp3 decoding chip. The AVR is also connected to the STA013 via the I2C bus to configure it. The STA013 accepts mp3 data from the controller and feeds it to a DAC, in this case the AD1857. The signal signal from the DAC is fed to a TDA7050 headphone amplifier. You can listen to the audio trough a crystal earphone.
The current design is now built on a breadboard but will be eventually migrated to a projectbox that makes it more or less portable.

This is how the board currently look likes, sound it emitted from the crystal earphone.



The controller currently used is a ATmega88, i chose this controller becouse... Well i had a bunch and the ATmega48/88/168 Series is my favorite.
In this application this controller has a big advantage. The mp3 player reads out a mp3 file via a SPI bus from the MMC/SD card. From there it has to be sent via SPI to the mp3 decoding chip. I reconfigured the USART unit in the AVR to become a SPI master unit, this greatly simplifies programming but best of all. Increses troughput of the AVR itself. The AVR will be clocked on slower speed to preserve power and high bitrate mp3's require quite some bandwith.
The leds are there for debug purposes.



For the MP3 decoder i used the STA013 decoder chip. You can buy it quite cheaply from the futurlec webshop for about 7 dollars. The VS1001K has a integrated headphone amplifier but i found it too expensive to buy. For 25 euro's i can buy 2 STA013's with the CS4340 DAC's to use them with and have money to spare for some microcontrollers.
The strange adapter is something i made myself with eagle cad software. It is basically a matrix of 1 mm copper squares that are on a 1.27 mm grid. Perfect for SOP and SOIC outline chips and some passives like 0805 and 0603. As a tip, pretinning the pads like i did, was a big mistake. For SMD you really need coplanarity, or the surface needs to be even.



This is the analog part with a AD1857 Stereo DAC and a TDA7050 stereo headphone amplifier. I now used the AD1857 becouse i got it as a sample from analog devices and it works perfectly.  But the main problem is that it is a 5V only part, so i need a 3.3V part. Lady Ada mintyMP3 uses the CS4340 DAC. The AD1857 is put on a TSSOP 28 SMD adapter from futurlec to make it suitable for breadboard use.

Update 27 january 2006

I have updated the player a bit:

I have exchanged the ADC to the CS4340 DAC and soldered on some homebrew SMD adapter board. The ATmega88 has been replaced by the ATmega168V (the normal ATmega168 was not available from futurlec). This controller has double the flash space so its perfect for more code. The demonstration also has a bit more sound instead of the very short "blub" sound. The blub sound was also played too fast at 22kHz, while the STA013 plays 44kHz. The new AVR has a bit more space for a mp3 sample and it features yours truly saying "Bla", i was quite happy when it worked. But it annoyed the hell out of me after a minute or so hearing my self saying "bla". The speaker is also a new addition. The headphone amplifier can handle it without becoming even warm.

I also made a MMC setup that for now is seperate from the current mp3 player. This is done becouse the USART has been set in SPI master mode to feed the STA013 mp3 data as fast as possible. Thats what i love about the ATmegaXX8 series, they basically have 2 spi busses. The newest ATmega1281 series has 4 usarts!!! You can set them anyway you want, imagine 2 UARTS and 2 SPI master controllers. I cant wait to get my hands on those (TQFP100 package).

Here you can see the MMC reader/write setup for now. The bottom cable goes to a MAX233CPP to translate the signals for the pc. (it is a 5V part, but works also at 3.3V).

Here is a closeup on the MMC/SD card slot. This one was ordered from farnell, item number 9186204. It is easy solderable as the feet and the connections are spaced by 2.54 mm's. The logic chip you see in the corner has a special function. It basically NAND's the pulled up reset pin from the avr (controlled by the programmer) and the pulled up chipselect that is afterwards inverted from the AVR. Why? Well usually when adding a ISP programmer you have to place resistors in parallel to the SPI bus to your devices, what results in non working code or bad signal integrity that are hard to debug (hence the scope probe). Well i got fed up with it and got some 74HC00's from farnell and hooked them up in that way. Now no resistors, but what about bus contention? Well when the programmer kicks in and pulls the RESET pin low to enter programming mode, it floats the CS pin high so the MMC/SD card releases its pins. The programmer can go on its merry way without fear of buscontention with the MMC. When the MMC is done, the 74HC244 in the programmer goes tristate.

Here is some more code of the mp3 player.
And here is the code for the MMC reader.

Both libraries are just a intermediate state. The mp3 player just emits a "Bla" from the creator of this page. The MMC card code just initialises the card (was a pain to get right) and retrieves the Card specification register. Still lots of work to do.

Update 11 november 2006

A fellow electronics hobbyist responded to my mp3 player design. I did not have a schematic design at all (I rarely make that, mostly on paper). He made a PCB design and I am trying to get it working, alas I do not have a JTAG II for AVR or i could program it without a problem, i need to do some modifications to the ISP connector.



Back

Last update at: 27-01-2006