chipKIT® Development Platform

Inspired by Arduino™

Unable to write to SD Card

Created Wed, 09 Jan 2013 14:15:20 +0000 by rrowe629


rrowe629

Wed, 09 Jan 2013 14:15:20 +0000

Hi all,

Currently having some difficulties writing to the micro SD card on the Chipkit WIFI shield. Main board is a Uc32 and I'm using MPIDE 0023. Searched for a similar problem, but didn't find it. Although my program is lengthy, I can demonstrate the problem with the "Files" example from the SD Library. This program runs fine out of the box - I get the expected responses regarding existence of the file named "example.txt". If I comment out the line that says "SD.remove("example.txt");", I also get the expected results - on the first pass, i.e., the file doesn't exist, then it does and then the sketch again reports that it exists. Exactly what you would expect.

Next pass, though, I would expect it to find the file since it was not removed. If I hit the reset button, it first reports that the file does not exist, then, after the open statement, it reports that it does and then, with the "remove" step commented, it again reports that it exists. If I pull the card at this time, though, and look at it on my macbook the file is not there. I even tried running the CardInfo code immediately after the exists function confirms the file's presence, but CardInfo does not report it being there either.

Running the Read Write example yields similar results - it reports that the write has executed (no errors are reported, either), but the sketch cannot open the file for reading because it's not there. If I manually add the file test.txt with my laptop, then put the card back in the shield, it opens successfully after the write, but is unchanged by the write and retains its original contents.

It's as if the card is somehow write-protected although none of the write statements generate any errors on the Serial monitor (not sure if they should, but they don't in any case). The card in formatted FAT32 (formatted on my MacBook with Disk Utility) with a capacity of 8GB.

Any ideas?

Thanks,

Roger


rasmadrak

Wed, 09 Jan 2013 20:20:18 +0000

I think it should be FAT16 formatted..? Maybe the FAT32 isn't fully compatible yet.

What brand is the card? Could it be that this particular brand simply reports writing to a write protected card as successfully but doesn't write anything?

Have you tested another card?


pito

Wed, 09 Jan 2013 20:39:30 +0000

Try to format it under Windoze.. Or, you may try: https://www.sdcard.org/downloads/formatter_3/


rrowe629

Thu, 10 Jan 2013 18:17:00 +0000

Thanks for the quick responses. The card is a SanDisk 8GB. Since it is a micro SD, there is no write protect switch on the card. It's the only microSD card I have so not currently able to test with another.

I did try both the Windows and the SD formatting tools, but still didn't work. Also tried formatting the card as FAT16 as instructed here:[url]http://forums.adafruit.com/viewtopic.php?f=31&t=7108[/url]. Still no joy.

Lastly, I hooked up an adafruit SD card reader just to see if it might be the WIFI shield, but had the same result.

Since it looks like I'll need to try another card, can anyone recommend a specific brand/capacity/format to which they have successfully written using the chipKIT WIFI shield?

Thanks,

Roger