|Home Feature Space Science Atheism Paranonsense Technology Offsite About Search|
|Home : Technology : MMC to Serial Adapter|
One of my friends and colleagues at work, Paul Gregory, recently bought a Palm V organiser. Like many of the smaller organisers, it does not have an expansion port capable of taking additional memory cards, so he searched around for an adapter for various memory card types with little success.
He did, however, come across some homebrew projects interfacing MultiMedia Cards (MMCs) to microcontrollers, including this MP3 Player designed and built by Peter D'Antonio and Daniel Riiff for their final year project at Cornell University.
Several features of MMCs pointed out by Peter and Dan sounded interesting: nonvolatile, relatively cheap, readily connectable using a 2.54mm pitch connector, low number of pins, and simple serial output. The "Atmel" microcontroller they were using sounded familiar as well, so he asked me about how easy it would be to use one as a more general interface. I'd used these chips before.
The result is this project here.
This page contains a snapshot of the project. Ongoing development may be found hosted on SourceForge, the open source software repository. The home page for the project is at http://sourceforge.net/projects/mmcserial/. If you want the latest code and information, please visit there.
The prototype hardware is laid out on Veroboard (stripboard), and consists of 2 chips and a few passive components, as well as the connectors for the RS232 serial connection and the MMC itself. The MMC connector for the prototype is an edge connector removed from an old floppy disk cable; I knew my habit of hoarding old computer bits and pieces would come in handy.
The two chips are an Atmel AT90S2313 microcontroller, which is effectively a small computer on a chip, and a MAX3223 RS232 level-shifter IC.
The microcontroller contains 2K of non-volatile flash memory, used to store the firmware that controls the reading and writing of the card. It also has a small amount of RAM, a UART for serial communication, and enough general I/O pins to interface to the MMC, with some to spare (8 known as Port B, and a further 7 as Port D - 2 of the Port D pins double up as the UART interface). At speeds below 4MHz, it will run at 3 volts, not coincidentally the same voltage as the card requires. This is most easily obtained from 2 AA alkaline cells in series.
The 3 volt operating voltage, however, causes problems when talking to a RS232 serial link. This requires a +/- 12 volt nominal voltage swing to communicate, which cannot be generated by the microcontroller on output, and worse, on input would destroy the chip.
Hence the second chip in the design, a MAX3223 level shifter. This is a wonderful (and cheap) piece of kit that generates its own +/- 12 volt levels and buffers both inputs and outputs appropriately. It has 2 input and 2 output buffers, enough to transmit and receive data, and also to deal with the RTS and CTS signals used for flow control between the host system and the adapter.
The transmit and receive signals from the host are routed the the UART pins on the microcontroller, so that data transmission can be dealt with in hardware. The RTS line goes to one of the other pins on Port D with a dual purpose - this one serves as an external interrupt, and can be used to wake the microcontroller from a power-down mode. This mode is used to keep current consumption to a minimum when reading or writing is not taking place.
Finally, a trio of status LEDs is connected to signal basic state information to the user.
The firmware's job is to relay instructions and data between the card and the serial port. The card's own command sequences are somewhat cryptic and require handshaking with the card, so a slightly higher level semantics was required.
Because of the limited space for the firmware, we decided that the best thing to do was to expose a sector-based interface to the card, and rely on the host to organise that into a coherent file system. This meant that the adapter would be useful for any file system and therefore any host with a properly configured RS232 port. That sounded like a good idea to us.
Complete details of the protocol for talking to the card, and annotated source code for the firmware, can be found behind the following links:
Both hardware design and firmware are licensed under the GNU Public License (GPL).
Well, two things come to mind immediately. One - implement some host software to make use of the adapter. It's quite happy in debug mode, connected to a terminal emulator, but it's not exactly user friendly. This development will be the main thrust of the project currently hosted on SourceForge.
The second task is to design a proper printed circuit board, make it, and source both proper MMC card connector. and a connector for the Palm. The edge connector used to hold the card in the prototype is easy to misalign, and its grip is firm enough to cause significant wear to the card contacts. If anyone knows of somewhere in the UK where we can source small quantities (i.e. 1) of a MMC connector, please let me know.
First, for more information on AVR Microcontrollers, see Atmel's Website which contains the latest data sheets and product information. The AVR Studio development software is also available for free from this site.
Paul Gregory is an active open source developer who is also involved in photorealistic 3D rendering. His Aqsis website has all the details and a gallery of impressive images.
Peter and Dan's MP3 Player project page was a very useful source of information about interfacing issues and helped avoid a few potential pitfalls during the design.
Sandisk, guardian of the MMC standard, publish the MultiMediaCard Product Manual (1.7 MB) from which all of the signal timing and command information was taken, and without which we would have been completely in the dark.
The popular Eagle layout software is available from CadSoft. It is free for educational and hobby use (limited by board size and number of layers).
Finally, there is a good online support and discussion forum at AVRFreaks.net which is a friendly and generally on-topic place, and is frequented by several of the guys from Atmel. You can also get the Atmel datasheets and both AVR Studio and AVR-GCC development systems from there.