S2313 MMC to Serial
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:
; Name: MMCSerial.asm
; Title: Adapter to communicate via RS232 with Multimedia Card.
; Version: 1.0
; Last updated: 2001.08.26
; Target: AT90S2313
; Application to interface a Multimedia Card with RS232.
; The card is operated in SPI mode, with the signals being attached to pins on Port B as follows:
; Pin B0 is used as the chip select for the card.
; Pin B1 is the data output to the card (=MOSI)
; Pin B2 is the data input from the card (=MISO)
; Pin B3 is the clock to the card (=SCK)
; Three status LEDs are wired to pins PB4, PB5, PB6.
; Communication with the host is via RS232 at 115,200 baud (8N1).
; The RTS and CTS lines are attached to pins D2 and D3 respectively,
; and the transmitter enable pin to pin D4.
; Clock speed is 3.6864 MHz, as required to get an accurate baud
; rate of 115200 baud.
- Build Process
All of these files should be loaded into an AVR studio project, with MMCSERIAL.ASM being the main target file. The build process should complete with no errors or warnings, and is then ready to be uploaded into the 2313 using whatever programming hardware is appropriate. I used the STK500, since its programming voltage can be set to 3V to match the voltage of the target board.
- Download all of the Eagle schematics, AVR Studio project files and documentation as a zip file (172KB),
or visit SourceForge for the definitive up-to-date releases and development progress.
● Further Development
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.
|M163 SD,MMC Interface|
|ATmega48 UDP/IP 적외선 리모콘 수신장치|