Man, you guys are in for a treat! Although this has been done before, people usually don’t attempt to do this while doing other things. In this case, I datalog. So I can have up to 6 servo’s going with different angles while I’m taking measurements every 200 ms. Pretty awesome!
I attached the code below, but I’m sure you will see this code again as I’m going to use this ATmega168 to control a Traxxas Slash RC car 🙂
Exciting times!!! Now I have a fully functional Raw SD/MMC library working on the ATmega168! This library isn’t optimized for Arduino, since I prefer making my own drivers. I have found many Arduino libraries for writing to SD/MMC cards, so there are other libraries available.
I created this library (with the help of at least 3 other libraries) so that I could log measurements and IO pins directly to a microSD card. Not only am I giving you the library (SD_Card.c, SD_Card.h), but I’m giving you all of my code so that you can see how everything is initialized. I also have a jpg of how to wire the SD card to the ATmega168. There is also a detailed Readme.txt that first explains the File Structure, Programming Environment, Programmer, Hyper terminal program used, then serves as a notebook, explaining some of the troubles I went through to get it to work.
Here are the stats for the things I have setup (2 timers, ADC, USART, SPI, and SD_card)
text data bss dec hex filename
7638 0 562 8200 2008 ATmega168_slash.out
FLASH: text + data
SRAM: data + bss
So for this software, I’m using 7638 bytes of Flash and 562 bytes of SRAM. For the ATmega168, there is 16K of flash and 1K of SRAM available, so there still is a good deal of room left.
Hope you guys enjoy this! I’m using Mercurial for version control, and I’m finding it very easy to use and helpful for figuring out if something went wrong.