MicroSD Card Sheild Backward Compatibility
hello forums,
i pretty new arduino programming, , have worked on several small projects before, first project have done involving writing sensor data sd card microsd card shield.
anyway, problem have have uno r2, , when searching online microsd card shield record data accidentally bought 1 pin configuration uno r3 (i.e., new 4 pins , other slight changes). bought stackable pin headers configured r3.
since these not fit properly, tried connecting between shield , board:
pin 8 cs/ss (recommended manufacturer opposed 4)
pin 11 mosi
pin 12 miso
pin 13 clk/sck
with jumper wires.
however, microsd card failed initialize when when used manufacturer's test code (below).
is there correct way wire microsd card shield arduino uno r2, , if not, suggest? appreciated, , sorry if appears bit of newbie question.
i pretty new arduino programming, , have worked on several small projects before, first project have done involving writing sensor data sd card microsd card shield.
anyway, problem have have uno r2, , when searching online microsd card shield record data accidentally bought 1 pin configuration uno r3 (i.e., new 4 pins , other slight changes). bought stackable pin headers configured r3.
since these not fit properly, tried connecting between shield , board:
pin 8 cs/ss (recommended manufacturer opposed 4)
pin 11 mosi
pin 12 miso
pin 13 clk/sck
with jumper wires.
however, microsd card failed initialize when when used manufacturer's test code (below).
is there correct way wire microsd card shield arduino uno r2, , if not, suggest? appreciated, , sorry if appears bit of newbie question.
code: [select]
// include sd library:
#include <spi.h>
#include <sd.h>
// set variables using sd utility library functions:
sd2card card;
sdvolume volume;
sdfile root;
// sparkfun microsd shield uses pin 8 cs
const int chipselect = 8;
void setup()
{
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
serial.print("\ninitializing sd card...");
// note if it's not used cs pin, hardware ss pin
// (10 on arduino boards, 53 on mega) must left output
// or sd library functions not work.
pinmode(10, output);
// we'll use initialization code utility libraries
// since we're testing if card working!
if (!card.init(spi_half_speed, chipselect)) {
serial.println("initialization failed. things check:");
serial.println("* card inserted?");
serial.println("* wiring correct?");
serial.println("* did change chipselect pin match shield or module?");
return;
} else {
serial.println("wiring correct , card present.");
}
// print type of card
serial.print("\ncard type: ");
switch (card.type()) {
case sd_card_type_sd1:
serial.println("sd1");
break;
case sd_card_type_sd2:
serial.println("sd2");
break;
case sd_card_type_sdhc:
serial.println("sdhc");
break;
default:
serial.println("unknown");
}
// try open 'volume'/'partition' - should fat16 or fat32
if (!volume.init(card)) {
serial.println("could not find fat16/fat32 partition.\nmake sure you've formatted card");
return;
}
// print type , size of first fat-type volume
uint32_t volumesize;
serial.print("\nvolume type fat");
serial.println(volume.fattype(), dec);
serial.println();
volumesize = volume.blockspercluster(); // clusters collections of blocks
volumesize *= volume.clustercount(); // we'll have lot of clusters
volumesize *= 512; // sd card blocks 512 bytes
serial.print("volume size (bytes): ");
serial.println(volumesize);
serial.print("volume size (kbytes): ");
volumesize /= 1024;
serial.println(volumesize);
serial.print("volume size (mbytes): ");
volumesize /= 1024;
serial.println(volumesize);
serial.println("\nfiles found on card (name, date , size in bytes): ");
root.openroot(volume);
// list files in card date , size
root.ls(ls_r | ls_date | ls_size);
}
void loop(void) {
}
how did wire power , ground? sd shield use 5v or 3.3v?
pete
pete
Arduino Forum > Using Arduino > Project Guidance > MicroSD Card Sheild Backward Compatibility
arduino
Comments
Post a Comment