Forum: Mikrocontroller und Digitale Elektronik JY-MCU und Arduino SD-Library


von Martin F. (pingufreak83)


Lesenswert?

Hi zusammen,

hat jemand das oben genannte Board und die SD-Library am laufen? Ich 
habe folgendes versucht, leider ohne Erfolg:

  lcd.print("Initializing SD card...");
  pinMode(12, OUTPUT);

  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    lcd.print("initialization failed. Things to check:");
    lcd.print("* is a card is inserted?");
    lcd.print("* Is your wiring correct?");
    lcd.print("* did you change the chipSelect pin to match your shield 
or module?");
    return;
  } else {
   lcd.print("Wiring is correct and a card is present.");
  }
  lcd.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      lcd.print("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      lcd.print("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      lcd.print("SDHC");
      break;
    default:
      lcd.print("Unknown");
  }
  if (!volume.init(card)) {
    lcd.print("Could not find FAT16/FAT32 partition.\nMake sure you've 
formatted the card");
    return;
  }
  uint32_t volumesize;
  lcd.print("\nVolume type is FAT");
  lcd.print(volume.fatType(), DEC);

  volumesize = volume.blocksPerCluster();    // clusters are collections 
of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of 
clusters
  volumesize *= 512;                            // SD card blocks are 
always 512 bytes
  lcd.print("Volume size (bytes): ");
  lcd.print(volumesize);
  lcd.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  lcd.print(volumesize);
  lcd.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  lcd.print(volumesize);
  lcd.print("\nFiles found on the card (name, date and size in bytes): 
");
  root.openRoot(volume);
  root.ls(LS_R | LS_DATE | LS_SIZE);

Ich vermute, dass ich die Pins in der SD-Library ändern muss, da sich 
die Arduino Pins von den JY-MCU Pins unterscheiden.

Beim JY-MCU sind die Pins wie folgt in der pins_arduino.h definiert:

static const uint8_t SS   = 12;
static const uint8_t MOSI = 13;
static const uint8_t MISO = 14;
static const uint8_t SCK  = 15;

In den SD-Beispielen steht jedoch folgendes:

 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4

Werden die Pins aus der pins_arduino.h automatisch richtig übernommen, 
oder muss ich die Lib tatsächlich irgendwo anpassen und "Pin"-Kompatibel 
machen?

Mit der Lib von Ulrich Radig funktioniert es super, also scheint alles 
richtig verdrahtet zu sein :).

Danke!

LG

Martin

: Bearbeitet durch User
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.