This tutorial describes how to build and use a micro SD card interface with the STRUIX system.
The basic connection diagram is outlined below. It should work with most Arduino example codes that support SD card storage, including SD_RAW by Roland Riegel and the SD card library included with Arduino 0022. Admittedely, we have not tried the Arduino SD library (yet), but it appears to be easily adaptable on first inspection. The major change to the Arduino SD library is to remap the CS (chip select) signal to uses D8 rather than the default D10. Happy coding!
UPDATE: See the change notes at the end of the page, to get the Arduino 0022 SD library working with STRUIX.
A simple application using a version of SD_RAW tailored for STRUIX is included in the attachments section below. Download and unzip the file to a subfolder in your Arduino Sketches directory.
CPU -------------- SD
D8 ========= >> CS (chip select) - part of the SPI bus *
D9 ========= >> CD (chip detect) - whether or not a card is inserted *
D10 ========= >> Not used
D11 (MOSI) ===== >> DI (Data In - from the SD card's perspective)
D12 (MISO) ===== >> DO (Data Out - from the SD card's perspective)
D13 (SCK) ===== >> SCK (SPI bus clock)
* D8 & D9 are pulled up to VCC (+3V) by 33k resistors.
Keep in mind, the STRUIX configuration reserves D8, D9, D10, D11, D12 & D13 for SPI bus components. For this single CPU/device combo, D8 is used as chip select. D10 is not used in this example. If multiple SPI devices were being controlled with this CPU, D10 could be used in addition to D8, to multiplex select up to 3 devices on the buss (3 devices + none). If using full size SD cards, D10 could also be used to detect write protect (WP) status as well.
1ea STRUIX Protopad One
1ea Micro SD Card break out board (Like Sparkfun #BOB-00544)
1ea Single-row, breakaway header (7 places)
2ea 33k - 1/4W resistors
Misc Jumper Wire
3mm F/F metal standoffs
3mm M/F plastic standoffs
3mm Machine Screws
Double Sided Foam Tape
In-Curcuit Programmer (ISP) project.
In the attachments section below is a version of Roland Riegel's SD_RAW, customized to work with the STRUIX configuration. It's a simple application that will confirm the operational status and display vital statistics about the SD card. Then the card is exercised by writing, then reading data and computing the block write duration in microseconds.
Keep in mind that this is a LOW LEVEL R/W application that will destroy any OS formatting on the SD card. It will need to be reformatted (FAT or FAT32 most likely) to work with the SD card library included with Arduino 0022 (or other FAT library for that matter).
Change the line below "//SPI port"
In all examples & applications that use the SD library:
2. In the setup() function, change the baud rate of
(or whatever your bootloader serial rate is)
3. Make sure pin 8 (CS) is set to output.
(In the example codes) Below the line:
Add the line:
4. Change the default CS pin.
Initialize the SD library with:
rather than the example default.