Pages: 1 ... 5 6 [7] 8 9 ... 11   Go Down
Author Topic: SD/MMC From the ground up  (Read 26161 times)
0 Members and 2 Guests are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I am having difficulty getting the demo to work.  I am running Arduino 0015 under Windows XP, using a 5V Arduino Pro and a breakout board for the memory card, both from SparkFun, and the SMB_LIBRARIES_2009-04-15 package.

  First, microfat2::initialize is assumed in the demo code to return an integer error code, but this version returns just a boolean.  It was easy enough to adjust the demo code to take care of that.

  Then, it claims falsely to work.
  • It prints its sign-on message
  • It gets past mmc::initialize
  • It gets past microfat2::initialize
  • It comes back from microfat2::locateFileStart reporting (via added code) that fileSize is 8186782 and that dp.m_sectorsAvailable is 15989
  • It says "All initialised OK!" and "Writing...," [size=14]but[/size] an added "print_P(PSTR("x"));" in the loop is never executed, and indeed
  • Nothing is written into the file
 Could there be another, more serious, incompatibility between the demo code and the infrastructure of the new SMB_LIBRARIES?

  Any help will be appreciated.

Robert R. Fenichel
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 79
Combat, please!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Robert.

Does the file size ring true? Is it the same as the data file you copied on?

How is the card formatted? What capacity is it? Was it cleanly formatted before copying the file on there?

Can you try a different card??

C

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the file size ring true? Yes. [/font]Is it the same as the data file you copied on? Yes.

How is the card formatted? FAT16, done from Windows What capacity is it? 1GB. Was it cleanly formatted before copying the file on there? Yes.

Can you try a different card?? I don't have another, but does this sound like a hardware problem?  I'd first try sticking some more probes into the code, if you can give me some suggestions as to placement.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 79
Combat, please!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm,

It's unlikely that a change to the library has caused an incompatibility  with the test sketch - the updated library zip only had a #include
case sensitivity issue fixed and a speed hike.

The fact that the card is recognised means that the hardware is probably OK. There is quite a lot of data being read to get that far. It never hurts to try different cards though.

Does the LED on port 13 flicker? That would indicate that an xfer is in progress. I it doesn't then it's probably a software issue.

Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I might interject (intrude).  :-?

I'm using a 1Gb Kingston SD card.  It is formatted Fat16(default) at an allocation of 64Kbytes by windows.  I then added over 200Kb of "data" (whatever you want, a bunch of o's or any other letter), then stored that data in a card file labeled "data". I didn't add the '.txt', as windows will do that automatically.

Using DPDemo, many, many Kbytes of the message, "the time is: xxxxxx", is written to the card, (about once per 38ms), until the word 'done' shows up in the serial monitor.

Having modified DPDemo, somewhat, for my purposes, the sketch will write that same message to the card once per second ( a time period that I can easily modify, if I want).  At that time base, I have been able to leave the sketch run for well over an hour, and data was continually added to the card during that time.  I don't know how much longer it would have gone on, since I stopped it myself.

End of intrusion, with my apologies.  :-[
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The fact that the card is recognised means that the hardware is probably OK.
Agreed; that's why I want to look further at the software.There is quite a lot of data being read to get that far. It never hurts to try different cards though.
Agreed again, and I will when I get a chance, but without much hope.

Does the LED on port 13 flicker? That would indicate that an xfer is in progress. I it doesn't then it's probably a software issue.
The Writing ... display goes by so fast that there's no time for a flicker; as I said, my probe shows that the top-level loop is traversed zero times.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  Is it plausible that this is a word-size problem?  I am on my way out the door for a business trip or I would check this out myself, but could it be that the size of my DATA.TXT is such that somewhere in the software, one of the routines is trying to squeeze that size (or it/512) into a too-small field, and coming up with a negative number that, in the way those things often work out, stops the loop?
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Intrusion #2  :-[ :-[
Make sure the baud rates match'

In DPDemo

Code:
void setup(void)
{
  Serial.begin(115200)

That's the baud rate of the sketch, serial monitor baud rate should match, if not strang looking heiroglyphics will appear, and I don't know if anything will show up on the card.

I'm not an expert on this stuff, just stumbled thru the whole thing, with sirmorris' help,;of course; until I got things working. smiley-wink

My wife is after me to get going someplace, gotta go.  :smiley
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 79
Combat, please!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might be on to something with the value wrap-around. I would try changing the loop, outputting a couple of hundred values. See if that has an effect. I haven't got a board handy at the moment to try it on.

@pakrat: No input is unwelcome! Apart from 250 volts input at the fingertips. That was pretty unwelcome. smiley-wink

« Last Edit: April 20, 2009, 02:01:31 pm by sirmorris » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  The problem is solved; I report the solution with some embarrasment, but out of a sense of duty to others who may blunder in the same way that I did.

  I had accidentally engaged the Lock switch on the carrier that adapts my uSD cards to the MMC form factor.  Silly me.  This is a write-protect switch, and all the rest follows.

  My first thought was to suggest that the write-protect (WP) and card-detect (CD) outputs of the breakout board should have been interrogated within mmc:initialize, but that redesign would probably be a mistake.  It would require tying up two more microprocessor pins for matters better handled by careful human procedures.

  
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 79
Combat, please!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I rarely use SD cards, and I wouldn't have thought twice about the /WP signal!

Thanks for posting this!

C
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I've been having some difficulty getting this to work - I keep getting the output "Error  Couldn't find data.txt on the card". Can somebody please help me?

I've used the exact code that pakrat put up on post #72 and the libraries recommended in the same post.

I'm using an Arduino Duemilanove and Adruino-0015 software.

I've checked circuit layout as per the 1st post by sirmorris and checked it is all connected between the SD card and arduino OK.

I've formatted the SD card to FAT, not FAT32 and saved a notepad file with text in it as "data.txt" (it's 32kb). I've tried two separate SD cards - a 2GB Extreme III and a 1GB SanDisk.

Now... I've run out of ideas - I'm quite new to this! :-[
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just label the card file "data", windows adds the .txt

From reply #94,   Pakrat
  
Quote
Re: SD/MMC From the ground up
Reply #94 - 20.04.2009 at 20:05:42  

I'm using a 1Gb Kingston SD card.  It is formatted Fat16(default) at an allocation of 64Kbytes by windows.  I then added over 200Kb of "data" (whatever you want, a bunch of o's or any other letter), then stored that data in a card file labeled "data". I didn't add the '.txt', as windows will do that automatically.

Also, read some of the later posts(beyond #72).  srmorris made some changes, and gave new information.

Pakrat

 
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 79
Combat, please!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

@Pakrat - You have just highlighted one more problem that had just clean slipped my mind! I've been struggling with this one. You are right - if you have windows set to hide known extensions, it goes ahead and adds them for you without asking.

Viz. If you save a file in notepad and add the .txt extension to the name, windows internally adds another meaning the file is called 'data.txt.txt'! The sketch won't be able to find this.

Thanks Pakrat  8-)

@J_T - You might want to check if 'Hide extensions for known filetypes' is checked in the folder options.

Open an explorer window and select the menu item Tools -> Folder Options. From there locate the option and check if it's checked.

Let us know!

I'll add code to print a directory of the card, this will add a new level of diagnostic.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pakrat, sirmorris,
you're on the money exactly. Well diagnosed, sorry I'm a bit of an idiot! smiley-razz

Thanks for your help.
J_T
Logged

Pages: 1 ... 5 6 [7] 8 9 ... 11   Go Up
Jump to: