Having problems with SD card

Dear sir/madam,

Recently I acquired a Renesas Sakura development board, to evaluate whether we want to use Renesas ICs in the future. One of the most interesting features was the microSD card slot that was already present, which is ideal for datalogging.

However, even the simple demo program that was posted in the reference guide does not work. I tried SD cards in three different sizes (1GB, 2GB and 8GB), formatted as both FAT16 and FAT32, and none of the six configurations works, all I get is the notification that no SD card was found (that is, SD.begin() results in false).

I was wondering, am I doing something wrong? Is my board faulty? What would be the best way to test this? 

The code I used is as follows:

#include <Arduino.h>
#include <SD.h>
 
void setup(){
    Serial.begin(9600);
    while(!Serial.available()); // wait to press key
    Serial.read(); //dummy
     
    if(!SD.begin()){
        Serial.println("Card failed, or not present.");
        while(1);
    }
}
      
void loop(){
    File file = SD.open("sample.txt", FILE_WRITE);
  
    if(file){
        //Write
        Serial.println("Success to open sample.txt and write hello.");
        file.println("Hello, my SD");
        file.close();
         
        //Read
        file = SD.open("sample.txt", FILE_READ);
        Serial.println("Reading file...");
        while(file.available()){
            Serial.print((char)file.read());
            delay(50);
        }
        Serial.println();
         
        //Size
        Serial.print("File Size:");
        Serial.println(file.size());
        file.close();
        digitalWrite(PIN_LED0, 0);
         
        //Remove
        Serial.println("Remove the file? y/n");
        while(!Serial.available());
        if(Serial.read() == 'y'){
            SD.remove("sample.txt");
            Serial.println("sample.txt has been removed");
        }
        delay(400);
 
    } else {
        Serial.println("Failed to open file.");
        digitalWrite(PIN_LED0, 0);
        while(1);
    }
}
 
Yours,
 
美月
Parents Reply
  • Dear Okamiya-さん

    This is correct. My DUT was using pin 11, so it didn't work. Pin 12 and pin 13 gave the same result.
    Great to hear it will be put in the reference, might save someone a headache someday.

    Thanks for trying to help though! 


    Yours,

    美月

Children
No Data