Pages: [1]   Go Down
Author Topic: Arduino SD library, SD.begin and ejecting the card  (Read 991 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone. Tried various searches and found a couple of threads that were close to my situation, but not quite.

The library is the SD library that comes with the Arduino IDE (1.0.1).

I have a system with an Arduino MEGA controlling all sorts of things. The instructions come from a text file on an SD card that the controller reads when I push a button. But, once I have completed one set of instructions, I have to eject the card and go to my computer with it to rewrite new instructions on it. Then I'll return to my Arduino, insert the card and press that button to get it going again. Arduino will not (and can not) reset in between.

But, the library tutorials don't say a word on what I should do in this kind of situation, the usual instructions just assume the card is mounted till power down.

So, when I press the button to activate reading from the card, should I always call SD.begin() to initialize the inserted card?

All I know is that the opened file have to be closed before ejecting, but as there is no SD.eject() to deinitialize the card I had to ask this.

Thank you for you time.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone, please?
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1251
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried to run an experiment like ejecting a crd many times to see if it all still works?

You could also look at the library to see what begin actually does and decide if you need to call it for each ejection.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried to run an experiment like ejecting a crd many times to see if it all still works?

You could also look at the library to see what begin actually does and decide if you need to call it for each ejection.
Don't have an Arduino to play with (yet), but I do need to code for it, so testing is out at the moment.

I'll take a look at the library to see if I can figure it out.
Logged

0
Offline Offline
Edison Member
*
Karma: 63
Posts: 1600
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately the Arduino SD library, SD.h, has a bug that prevents initialization of a new card by calling SD.begin().

SdFat allows begin() to be called multiple times.  There is no end() call, you only need to close all files before removing the card.

Once the new card is inserted, call begin() to initialize the new card. 
Logged

Pages: [1]   Go Up
Jump to: