High capacity multimedia cards in embedded systems
Multimedia cards are popular around us. There are well known Compact Flash, CD, MMC Memory Stick. Usually when you make new design with external memory you usually are considering EEPROM or Flash ICs with some capacities with up to few Mb. But why limit yourself, because in some cases it is smarter to add multimedia card socket and use any capacity (even few Gb) multimedia cards in your projects. Using removable storage cards you get few advantages:
-
You can share data from your card with any device that has reader;
-
You can have any size of storage memory;
-
Easier to get one than specific IC;
-
Cost effective;

What I really like about Using multimedia cards is that you can get huge amounts of storage of price small EEPROM or Flash IC. They are cheap because of mass production. They are available everywhere: digital cameras, Mobile phones, personal players, etc. Another advantage is that you can store data in format that PC understands. This way it is easy to collect data for later analysis using PC software.
MMC and SD cards
Multimedia cards(MMC) and SD-Media cards are compatible. Connectors are really cheap an easy to solder:

Bellow is an example how to connect MMC card to 5V microcontroller using resistor dividers:

As you see MMC card communicates in SPI mode. SPI is serial communication protocol similar to I2C but in many ways simpler. Many microcontrollers like AVR family have built in hardware SPI interface and can run in high data rates up to 100 times faster than I2C.
Interfacing to MMC card isn’t difficult just remember that MMC cards can be powered from 1.6V to 3.6. The picture above is an example of connecting to 5V system with voltage dividers.
Few words about how MMC cards work
MMC cards are not only a Flash memory block, but it also has a small controller inside that is responsible for initialization, identification and control. In SPI mode You have to send commands to set up card. Commands are typically five bytes – one byte command and four bytes of parameter and optional check byte. Check bytes are not used if they are not enabled. Check bytes are to make sure that communications goes without corruptions.
Most of commands return a response message which has to be clocked out from a card by sending a 0xFF. See details in specifications. What actions must be taken to start working with MMC:
-
When card is powered up, send a Reset Card command;
-
Then send Initialise Card command which takes some time;
-
After Initialization is complete you must retrieve card identification (16 byte). Identification contains manufacturer info, card type, amount of memory in the card.
-
Then read write the card information.
Read and write commands uses 32 bit address parameter that allows addressing up to 4GB of memory. Reading can be done from any address and you can read bytes by writing 0XFF bytes to latch out further data. Writing takes more efforts, because memory in the cards is organized in 512 byte groups called sectors. So when writing sectors, the card erases it firstly and then writes data. This is tricky if you want to update a single byte. Usually you would need additional 512 bytes of ram to read whole sector, update ir and then write. To make things easier there is a command which allows to set read and write buffer block size. If block size is set to 512, then read/write command start from 0 or 512, or 1024 …
There are more commands like protection, multi-block write that are documented in specifications.
Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post | TrackBack URI for this post
New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …Programming AVR ADC module with WinAVR,Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut … |
New on WinARM Tutorial
What are differences between WinARM and WinAVR,Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …LPC2000 watchdog timer,As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount … |

May 8th, 2007 at 1:30 am
Thanks for great information, Really I was looking for this info ….
I want to ask if there is a sample application demonstrating the use of this technique with some microcontroller like the AVR
May 9th, 2007 at 9:47 am
How to drive SD cards look at this source: http://www.ulrichradig.de/index.html .
I didn’t have a chance to try by myself yet.