📄 index.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>sd-reader: MMC/SD card example application</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li id="current"><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul></div><h1>MMC/SD card example application</h1><p>This project is a small test application which implements read and write support for MMC and SD cards. It includes<ul><li>low-level <a class="el" href="group__sd__raw.html">MMC read/write routines </a></li><li><a class="el" href="group__partition.html">partition table support </a></li><li>a simple <a class="el" href="group__fat16.html">FAT16 read/write implementation </a></li></ul><h2><a class="anchor" name="circuit">The circuit</a></h2>The curcuit board is a self-made and self-soldered board consisting of a single copper layer and standard DIL components, except of the MMC/SD card connector.<p>The connector is soldered to the bottom side of the board. It has a simple eject button which, when a card is inserted, needs some space beyond the connector itself. As an additional feature the connector has two electrical switches to detect wether a card is inserted and wether this card is write-protected.<p>I used two microcontrollers during development, the Atmel ATmega8 with 8kBytes of flash, and its pin-compatible alternative, the ATmega168 with 16kBytes flash. The first one is the one I started with, but when I implemented FAT16 write support, I ran out of flash space and switched to the ATmega168.<h2><a class="anchor" name="pictures">Pictures</a></h2><div align="center"><img src="pic01.jpg" alt="pic01.jpg"><p><strong>The circuit board used to implement and test this application.</strong></p></div><div align="center"><img src="pic02.jpg" alt="pic02.jpg"><p><strong>The MMC/SD card connector on the soldering side of the circuit board.</strong></p></div> <h2><a class="anchor" name="software">The software</a></h2>The software is written in pure standard ANSI-C. Sure, it might not be the smallest or the fastest one, but I think it is quite flexible.<p>I implemented a simple command prompt which is accessible via the UART. With commands similiar to Unix you can browse different directories, read and write files, create new ones and delete them again, and browse different directories.<p> <p> The following table shows some typical code sizes in bytes: </p> <table border="1" cellpadding="2"> <tr> <th>layer</th> <th>code size</th> <th>static RAM usage</th> </tr> <tr> <td>MMC/SD (read-only)</td> <td align="right">1002</td> <td align="right">0</td> </tr> <tr> <td>MMC/SD (read-write)</td> <td align="right">1178</td> <td align="right">516</td> </tr> <tr> <td>Partition</td> <td align="right">394</td> <td align="right">0</td> </tr> <tr> <td>FAT16 (read-only)</td> <td align="right">3316</td> <td align="right">0</td> </tr> <tr> <td>FAT16 (read-write)</td> <td align="right">6158</td> <td align="right">0</td> </tr> </table> <p> The static RAM in the read-write case is used for buffering memory card access. Without this buffer, implementation would have been much more complicated. </p> <p> Please note that the numbers above do not include the C library functions used, e.g. malloc()/free() and some string functions. These will raise the numbers somewhat if they are not already used in other program parts. </p> <p> When opening a partition, filesystem, file or directory, a little amount of dynamic RAM is used, as listed in the following table. </p> <table border="1" cellpadding="2"> <tr> <th>descriptor</th> <th>dynamic RAM</th> </tr> <tr> <td>partition</td> <td align="right">15</td> </tr> <tr> <td>filesystem</td> <td align="right">26</td> </tr> <tr> <td>file</td> <td align="right">49</td> </tr> <tr> <td>directory</td> <td align="right">47</td> </tr> </table> <h2><a class="anchor" name="adaptation">Adapting the software to your needs</a></h2>The only hardware dependent part is the communication layer talking to the memory card. The other parts like partition table and FAT16 support are completely independent, you could use them even for managing Compact Flash cards or standard ATAPI hard disks.<p>By changing the MCU* variables in the Makefile, you can use other Atmel microcontrollers or different clock speeds. You might also want to disable write support completely by changing the corresponding defines in the <a class="el" href="sd__raw__config_8h.html">sd_raw_config.h</a> and <a class="el" href="fat16__config_8h.html">fat16_config.h</a> files.<h2><a class="anchor" name="bugs">Bugs or comments?</a></h2>If you have comments or found a bug in the software - there might be some of them - you may contact me per mail at <a href="mailto:feedback@roland-riegel.de">feedback@roland-riegel.de</a>.<h2><a class="anchor" name="acknowledgements">Acknowledgements</a></h2>Thanks go to Ulrich Radig, who explained on his homepage how to interface MMC cards to the Atmel microcontroller (<a href="http://www.ulrichradig.de/">http://www.ulrichradig.de/</a>). I adapted his work for my circuit. Although this is a very simple solution, I had no problems using it.<h2><a class="anchor" name="copyright">Copyright 2006 by Roland Riegel</a></h2>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation (<a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>). <hr size="1"><address style="align: right;"><small>Generated on Thu Mar 16 13:43:58 2006 for sd-reader by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -