Monday, January 10, 2005

MP3 Playa

Not long after arriving at Cambridge, the Memory Stick connection in my PDA broke.. So, i'm now without an MP3 player.. Sad... After shopping around for an MP3 player, I've decided that none actually fit my bill... That's when the thought of building my own MP3 player came into being.. Then, after doing some research, I've decided that it is definitely plausible.. Many others have done it and I think that having my own MP3 player is just plain cool.. Even if it's all bare bones without an iPod finish, it'll still trump the iPod (in my heart), because I built it myself.. Hehe..

So, this is the basic plan.. I will build the MP3 player using the following devices:

  • PIC18F2410 (16kb Flash, 768b RAM, 28pin DIP/SOIC)
  • STA013 (10MHz, 28pin SOIC)
  • CS4334 (8pin SOIC)
Why an STA013 and not a MS3507D or VS1001K?? Because I can get it for under $7 online and the CS4334 for under $3 from the same place.. Many other people have successfully used this combination.. So, why reinvent the wheel?? Why the PIC?? Because I love the PIC.. For the STA013, you need to download a 'config' file each time into the device.. the size of the file is about 4kb.. So, with the F2410, I can store the config file in the flash and still have another 12kb of flash to play with..

I plan to use the MMC/SD card as the main storage medium.. They're quite cheap now.. current prices are sub RM300 for 1Gb of storage.. And it's small.. the RS-MMC makes it even smaller.. And now that SD has announced building in USB mass storage into the cards so that they can connect directly to USB, it just makes sense.. Also, I will be using a graphical LCD from the Nokia 3310 phones as the display device.. This gives me 84x48 pixels or 14x6 lines of characters with a 7x5 font size.. which is plenty of space.. Oh yeah, little pushbuttons for user input..

All of them, the MMC/SD + LCD + STA013, make use of SPI communications.. Since the PIC18 has a built in MSSP in SPI master mode, I will put all these devices on a main SPI bus with seperate control lines for each of them (not actually necessary)..
  • MMC/SD (2-way SPI communication, most active device)
  • STA013 (1-way, can be connected directly to MMC to bypass PIC)
  • LCD (1-way)
The STA013 uses I2C for sending control information.. And the PIC doesn't have an extra I2C port.. But since we will hardly be sending any control information, we will just bit-bang it.. We will use two PortB lines for this (due to the fact that they have internal pullups - hope it works).. We will only use the I2C for the following functions:
  • Downloading Config File
  • Setting/Reading Volume
  • Setting/Reading Treble/Bass Boost
  • Setting/Reading Cross-Over
  • Reading MP3 header information
The other PortB lines will be used for the 4 push buttons (KBIO), and STA013 RESET# and DATA_REQ lines (INT2)..

By running with INTOSC, the PIC18 can run either at 8MHz or 32MHz.. This gives us a safety margin in case our software is inefficient.. at 8MHz, SPI will run at 2Mbps.. well within the SPI speed and well above the required 320kbps that is the maximum for typical MP3s.. If necessary, we can connect the STA013 directly to the MMC and have the MMC feed in the data by-passing our PIC18, effectively doubling our communication bandwidth.. But I think that all these would not be necessary as the 2Mbps speed is fast enough to handle everything..

As for the software, it will be 100% interrupt driven.. The PIC will respond to the following interrupts:
  • STA013 Data Request (INT2)
  • LCD Update Timer
  • Pushbutton Events (KBIO)
INT2 is for the DATA_REQ line from the STA013.. This line will be edge triggered and will indicate that the STA013 needs to be fed with more data.. From various sources, I have gathered that we can send at least 4 bytes but to be safe, we will just poll this line and keep sending it until the line is deasserted in the ISR.. At 2Mbps, we will very quickly fill up the FIFO.. The LCD Update Timer will be used to update the LCD at a rate of up to 20FPS.. This uses about 80kbps, only 4% of the SPI bus.. This leaves the other 96% of the bus for purely MP3 comms..

Well.. That's all for the hardware.. We will dwell into the software at another time.. Still haven't actually sat down to think about the software.. Just that a graphical LCD allows us to do wonders with the UI.. And 4 pushbuttons.. Reminds me of a Siemens phone UI...