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."
);
(1);
}
loop(){
File file = SD.open(
"sample.txt"
, FILE_WRITE);
(file){
//Write
"Success to open sample.txt and write hello."
file.println(
"Hello, my SD"
file.close();
//Read
file = SD.open(
, FILE_READ);
"Reading file..."
(file.available()){
Serial.print((
char
)file.read());
delay(50);
Serial.println();
//Size
Serial.print(
"File Size:"
Serial.println(file.size());
digitalWrite(PIN_LED0, 0);
//Remove
"Remove the file? y/n"
(Serial.read() ==
'y'
){
SD.
remove
(
"sample.txt has been removed"
delay(400);
else
{
"Failed to open file."
Yours,
美月
Dear Okamiya-さん
I have attached the .bin file. The serial monitor is running at 9600 baud.
SD reading.zip
I hope you can help me further tomorrow.
Hi Mitsuki-san,
It works fine on my Sakura as seen below screen. There seems to be no problem on your software.
I used 4GB micro SD. Arduino library supports SD, SDHC so I think there is no problem with your SD. Please confirm your Sakura if it had physical damage at SD socket.
Dear Okamiya-さん Thanks for all the help you provided. The problem has been resolved now. It appeared that my DUT messed up the connection. Once I removed all connections to the DUT, the SD card function worked flawlessly. The SPI pins, pins 11, 12, 13, should be avoided, apparently. Maybe it would be nice to add this to the reference page at http://gadget.renesas.com/en/reference/sakura/library_sdmmc.html to avoid future problems. Yours, 美月
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, 美月