Pages: [1]   Go Down
Author Topic: What is the proper procedure to mount/unmount SD card with SD library?  (Read 1242 times)
0 Members and 1 Guest are viewing this topic.
Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having some doubts that I did mount/unmount of SD card correctly. I often get errors when using Sd cards on adafruit data logger shield, such as not able to begin.

I suspect that just inserting the SD card and pulling it out is not the proper procedure.

Before I can unmount an SD card, do I need to call any function to stop it?
If I insert the card again, do I need to start it before reading from it?
If I have opened a file to write on the SD card and then remove the SD card, when I insert the card again, will I be able to just continue to write on the same file or do I need to reopen it?

I wish someone has answered my question about the whereabout of the SD library manual.
Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Before I can unmount an SD card, do I need to call any function to stop it?
You need to close any open files.

Quote
If I insert the card again, do I need to start it before reading from it?
No. The device has no way of knowing that the card has been inserted/removed.

Quote
If I have opened a file to write on the SD card and then remove the SD card, when I insert the card again, will I be able to just continue to write on the same file or do I need to reopen it?
Neither. Removing the card without closing the file corrupted it.

Quote
I wish someone has answered my question about the whereabout of the SD library manual.
There are a number of variations of "the SD library". You weren't specific enough.

In any case, nothing that the library does differs in any radical way from reading/writing files on a PC, except that the media is removable.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Paul. I will make some changes to my code to see if closing and reopening the file will eliminate all the errors.

I am using this library from adafruit:

https://github.com/adafruit/SD

I looked "everywhere" but can't find a documentation. Hope someone can point me to it.
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Something I got from adafruit forum:

Quote
Once you remove the card the serial connection is broken / severed and you must re initialize the connection.

Documentation: http://arduino.cc/en/Reference/SD
Logged


Pages: [1]   Go Up
Jump to: