Issue with SD Card Sample Code

Ok, so I got my FEZ Cobra in a few weeks ago and have been messing around with it quite a bit. I am very impressed.

I have had a relatively easy time until I started messing with SD cards. I am using the code verbatim from page 60 of the “Beginners guide to NETMF”

I get this exception when running on my cobra

[quote]The thread ‘’ (0x2) has exited with code 0 (0x0).
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHIElectronics.NETMF.IO.PersistentStorage::.ctor [IP: 0000] ####
#### Test.Program::Main [IP: 0007] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.IO.dll
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.IO.dll[/quote]

The exception happens no matter what, SD card inserted or not.

The line of code that excepts is

PersistentStorage sdPS = new PersistentStorage("SD");

I will post the entire code from the guide if anyone would like.

Does anyone have any idea what is going on here? I have searched around this forum and have not really found anyone else experiencing a similar issue. I have tried pretty much everything that is in my knowledge to do


Matt P

This same question has been asked and answered about a dozen times. :slight_smile: While the ‘Search’ tool on this forum is not the greatest it would likely answer your question in about 5 minutes.

Not trying to be rude or anything just trying to point out the built in tools that can answer many questions very quickly.

Sometimes you may need to insert a Thread.Sleep after creating the PersistantStorage, some SD cards also create a big power spike when starting up and an extra cap can help.

matthewpapa, does your code work if you step in the code? Stepping on each line will make everything runs slower which can show us if delay is needed.

Jeff, I blame this on us, the search feature is still in progress and the “search” is somewhat hidden. We are working on making this more user friendly.

You can also use google like: ‘sd card’. Having a good search tool is essential, I’m sure you guys will get it fixed up as good as the rest of the site is getting now.

Yep, I am sure you have seen the new main GHI website, this one is next.

This is weird. If you are using the same exact code, you shouldn’t have problems. Do you have other SD cards to try?

Thank you all for your quick responses

Sorry if this has been asked before. I honest to goodness did search a few pages of the forum, as well as googled the error message. I will use the search optimization tip that Jeff mentioned in the future.

@ Mike: The error happens whether an SD card is inserted or not. I dont think the code even gets to the point to where it has a chance to see if there is a card or not.

I tried inserting a sleep statement after the creation of the PersistantStorage instance. No dice

So I guess from here I should try and power this thing with something more than what my USB bus provides because the spec’d 500mA isnt enough?

i’m glad you said spec’d because in reality that’s a pretty wide target. I’ve seen many PCs and even after-market USB cards that don’t put out a regular supply, or have enough voltage drop to play havoc with devices. Granted, your typical mouse or keyboard won’t care, but when you’re trying to run things that use towards the top end of the scale they just werent reliable

[quote]I tried inserting a sleep statement after the creation of the PersistantStorage instance. No dice
Ok this is a completely different situation. Before, the PersistantStorage is throwing the exception meaning you will not get to the delay after it.
You will get an exception if the card is NOT inserted… same if there are problems communicating with the card.