Many of our projects provide an interface with a memory card for data storage. These include the Music and Speech Recorder (August 2009), the Webserver in a Box or WIB (November 2009 to January 2010), the DAB+/FM Tuner (October to December 2010), the Digital Lighting Controller (October to December 2010) and the USB Data Logger (December 2010 to February 2011).
The memory cards used with these projects can be MultiMediaCards (MMC; up to 16GB), Secure Digital (SD; up to 4GB) or Secure Digital High Capacity (SDHC; up to 64GB).
In each case, we interface with these devices in “1-bit” mode, which is like the Serial Peripheral Interface (SPI) protocol.
It is a 4-wire bus utilising a clock line (driven by the micro), two lines for bidirectional serial data transfer and a chip select line, to activate the memory card and indicate the start and end of data packets.
In the later model MMC cards and for all SD and SDHC cards, there is also a “4-bit mode” which provides faster data access and an expanded set of commands.
Virtually all computers and most other devices which require high speed data transfer (eg, digital still and video cameras) use this mode. The 1-bit mode is provided primarily for use with microcontrollers, to reduce overhead and complexity.
Some readers have reported that certain memory cards do not work in these projects.
We have previously released firmware updates for some of these projects to address bugs in the memory card routines, for example some early versions did not work with 2GB SD cards.
These cards report information in a different way to all other SD cards and the early software versions did not include a special case to handle them. All of our current firmware releases incorporate this fix.
However, some cards were still not being properly recognised. One reader kindly sent us the SD card in question so that we could figure out what was going on.
Ultimately we tracked the bug down to what seems to be an error in the memory card controller itself. We suspect that this is not normally noticed since it only seems to affect operation in 1-bit (SPI) mode.
Updated firmware is now available for all the previously mentioned projects on the SILICON CHIP website.
They contain a work-around which allows these problematic memory cards to be used with our projects. The DAB+/FM Tuner and Digital Lighting Controller contain software “bootloaders” which allow the firmware to be updated without any special tools.
For the other projects, a programmer (such as the PICkit3) will be needed to install the updated code.