chipKIT® Development Platform

Inspired by Arduino™

Trouble with SD on WF32

Created Fri, 10 Jan 2014 03:35:51 +0000 by thinkpeace


thinkpeace

Fri, 10 Jan 2014 03:35:51 +0000

I'm trying to run the WebServer example on the WF32, but it gives the messages, "Unable to find SD Card Reader or filesystem".

I tried a 1GB and 2GB SD card that I can read OK on my computer, formatted FAT. The cards have the sample HomePage.htm on them. I'm using the SD slot on the WF32, no other sheilds installed.

The WiFi reports that it is connecting OK and is obtaining an IP address using DHCP.

Is there something I'm overlooking?

Thanks in advance,

Eric


KeithV

Fri, 10 Jan 2014 23:41:19 +0000

You should try formatting FAT32. Also you should use a ScanDisk SD card as some cards like the Memorex cards come up in native mode instead of SPI mode. The SD library assumes SPI mode and is what the SD spec (as written by ScanDisk) says the card should come up in.


matgyver

Sun, 12 Jan 2014 20:30:06 +0000

I am also having the same problem as thinkpeace with the SD card and the WF32. However, if I take that exact same SD card, stick it in a WiFi shield on a MAX32 and load the same firmware it works just fine. So I don't think the problem is with the SD card.

Any other suggestions?


pito

Mon, 13 Jan 2014 17:16:39 +0000

I worked with many micro SD and SDHC sdcards on pic32mx (128MB - 4GB, apacer, sandisk, kingston, nokia, etc). The most issues may come from:

  1. sdcard adapter (wiring, pullup resistors, good decoupling)
  2. power sources (an sdcard can take ~100 mA current easily)
  3. the sdcard driver. When none 1,2,3 issues then it works fine (20MHz SPI clock).

thinkpeace

Tue, 14 Jan 2014 02:37:25 +0000

One of the SD cards I'm using is generic (2GB), and one is SanDisk (1GB). I tried formatting FAT32, but it still doesn't work.

Any other suggestions?


thinkpeace

Thu, 16 Jan 2014 00:57:26 +0000

I tested the 1GB SansDisk SD card on an Arudino Ethernet using the SD Files example, and it works fine.

Using the same SD on the wf32 I get "Initialization Failed" when running the Webserver example or the SD Files example. In the SD Files example, I set the SS pin number to 51, and also tried without specifying the SS pin number.

It looks like the SD interface is not working. Am I missing anything?


majenko

Fri, 17 Jan 2014 15:11:06 +0000

Just taken delivery of a nice shiny new WF32 board, so I can get to grips with this problem now.

From the manual (you did read that, didn't you?) I see:

The SD card is accessed using an SPI interface on PIC32 microcontroller pins dedicated to this purpose. The SD library uses a ‘bit-banged’ software SPI implementation to talk to SD cards. On the WF32 board, the I/O pins used to communicate with the SD card are dedicated to that function and not shared with other uses.

Also:

Pin IO Name Func
49  1  RG15 AERXERR/RG15 SD Card
50  95 RG14 TRD2/RG14 SD Card
51  96 RG12 TRD1/RG12 SD Card
52  97 RG13 TRD0/RG13 SD Card

But there is no reference to say which pin is which.

Buried in the source code to the SD library I find this:

#elif defined(_BOARD_WF32_)
        //uc Pin 52
        #define prtSDO              IOPORT_G
        #define trisSDO             TRISG
        #define latSDO              LATG
        #define bnSDO               BIT_13

        //uc Pin 49
        #define prtSDI              IOPORT_G
        #define trisSDI             TRISG
        #define latSDI              LATG
        #define bnSDI               BIT_15

        //uc Pin 50
        #define prtSCK              IOPORT_G
        #define trisSCK             TRISG
        #define latSCK              LATG
        #define bnSCK               BIT_14

That means pin 51 must be the CS pin as you have rightly mentioned.

So, load the CardInfo sketch, set the chip select to 51, and lo - it works. In MPIDE, that is - it seems that software SPI in the UECIDE doesn't work any more since I added hardware SPI support.

So... make sure you have a version of MPIDE recent enough to have a version of the SD library that has WF32 support in it, and it should work fine for you.

By the way, the WF32 code was added to GIT on 2013-07-23, so anything newer than that should be fine.

Now to get and fix the software SPI problem in the UECIDE library... :/


majenko

Fri, 17 Jan 2014 17:06:31 +0000

Ok, it works in UECIDE now (absolute latest version with the newest chipKIT core) with just a minor change to how you use it.

The WebServer example from digilent works with HTMLSDPage.cpp changed to include

Sd2Card card(52, 49, 50, 51);
SDClass mySD(card);

#define SD mySD

at the top in the "SD Card Reader variables" section.


thinkpeace

Fri, 17 Jan 2014 18:30:26 +0000

majenko, Thanks for your help.

If I understand you correctly, if I have a version of MPIDE that is dated 2013-07-23 or newer it should work fine.

The version of MPIDE I have is the one on the WF32 page (http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,1193&Prod=CHIPKIT-WF32) dated 2013-07-24.

I set the SS to pin 51, const int chipSelect_SD_default = 51; // Change 10 to 53 for a Mega

and the CardInfo and File examples fail to initialize. What version of MPIDE are you using? Is there a newer version available?


majenko

Fri, 17 Jan 2014 19:39:16 +0000

I was using the git repository version. There's a sticky in the MPIDE section of the forum with the latest releases listed in it - grab the latest test release from there and try it.


Ian_B

Fri, 17 Jan 2014 19:49:29 +0000

Try using a newer version of MPIDE. I tried that example on 20130715 and ran into the same problem with the SD card, but was able to have it recognized using 20131118-test.

You can download the latest release here:[url]http://chipkit.s3.amazonaws.com/index.html[/url]


thinkpeace

Fri, 17 Jan 2014 20:57:00 +0000

Thanks. That fixed it!

I used version 20131118-test which I got here: http://chipkit.s3.amazonaws.com/index.html

That link should probably be on the page for the WF32. Also, the link for the MPIDE should be of a newer version.

Now I need to get back to porting the RFMB, low-cost low-power RF tranceiver, to MPIDE. The ChipKit WF32 would make a great gateway between a low-power RF network of Moteino's and the Internet.

ChipKit & RFM12B thread: http://chipkit.net/forum/viewtopic.php?f=18&t=2622


Max44

Sat, 19 Apr 2014 22:26:41 +0000

Ian

Thanks for this post! I was attempting to bring up the webserver demo on a WF32 board I just received and had the same problems with the SD interface. I was using a 2GB Sandisk card that I knew worked in SPI mode in another system. Switching to use MPIDE version 20131118-test worked for me too.

I have to wonder why? Library updates?

For information, for the SanDisk microSD 2GB cards I was using in the SPI mode, I bought one that didn't work. I'm not sure it's significant, but it had no CE marking on the back like two I had that did work.

Thanks again!

Max


Max44

Sun, 04 May 2014 15:41:07 +0000

Just as a followup, the recent MPIDE version 20140316 works with the WF32 microSD card.

  • Max

Jacob Christ

Wed, 07 May 2014 00:16:51 +0000

The WebServer example from digilent works with HTMLSDPage.cpp changed to include

I thought filenames needed to be 8.3?

Jacob


cblackburn1099

Sat, 13 Dec 2014 03:18:48 +0000

old thread ik now, but i just wanted to say that i had trouble with the sd card at first and i found this thread fascinating. but for others trying to get the card info sketch working, i have a WF32 i got at the 2014 masters.

I tried port number 51 and that didn't work, but i found it would with port 52. Speed isn't necessary for me right now as it's just pulling config files from the SD card.

Here's the info from the board description that was on the site:

Pin 51 (RB14): SD_SCK3 Pin 52 (RC03): SD_SS3 Pin 53 (RB10): SD_SDI3 Pin 54 (RC04): SD_SDO3

Now to try and get the damn Wifi Working lol