Part of a project that I am working on to measure the temperature and log it, involves writing to an SD Card (reading from it is not so important). So as part of this I purchased some items from the Proto-Pic website, one of which was an SD Card breakout board which came with, as a new person to this, I felt, next to no direct guidelines or instructions on how to wire it up. Sure, there’s schematics and the SanDisk pin-outs. However, nothing particularly clear as to what, connects, to what.
Paul Brook has on his wiki, the pin-outs for the Minimus32 which clearly shows the SPI (that’s effectively how to communicate over serial) but translating this to the break-out board was troublesome. However, after trial and error and running out of memory, I discovered the following works:
SCK /10 -> CLK
SS /9 -> D3
MOSI/12 -> CMD
MISO/13 -> D0
The first problem I had to overcome was the fact that the Minimus32 has 1k of RAM to work with, some of which is used up by variables, ,code running, etc. This was exasperated by the fact that the library I was using to talk to the SD Card, attempting to use FAT32, was quite bulky.
Thankfully, there is an alternative, FAT16 based library that claims to take up much less memory. The difference? This means that really, I can’t write gigabytes of data to an SD Card. When all I’m doing is logging temperatures, I don’t need that much data.
This FAT16 library requires a bit of hacking to get to work with the Minimus32, it requires a profile for the AVR_AtMega32u2 else it cannot identify the chipset, this is so that it can set the aforementioned PINs properly (I think it’s in SDCard.h in the library, which you put in the sketchbook/libraries/Fat16 folder) and be able to communicate with the SD Card.
In fact, it was this library, which because it was smaller and wrote out to the Serial (monitor-able using the Arduino IDE or HyperTerm or equivalent) gave me an error code which let me work out which cable I had connected incorrectly. (I had the CMD and CD connections crossed on the break-out board).
Damn I was joyous.Comments Off on SD Card Writing with the Minimus32