Pages: [1] 2 3   Go Down
Author Topic: Reading/Writing SD/MMC Cards Via SDI  (Read 2526 times)
0 Members and 1 Guest are viewing this topic.
Huntsville, AL, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm stuck at work, but I keep running across these cool things to try with my Arduino, but don't have the time yet...

These two links describe how to use an old floppy drive connector as an SD card slot and tell how you can use one in MMC mode using SPI and five pins (3.3V, GND, clock, data in, and data out). As it happens, I had been thinking about how to store some configuration data for an Arduino program and update it without connected back to the computer or adding an interactive input device.

Does anyone of any reason why this technique wouldn't work with an Arduino program? If I'm reading all of this right, it appears that you could write a bunch raw data to a card (maybe using a tethered Arduino), then read the card from another program running standalone. This would also be great for long-term data logging, wouldn't it?

http://uanr.com/sdfloppy/

http://wiki.openwrt.org/OpenWrtDocs/Customizing/Hardware/MMC
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was thinking of eventually getting around to doing this. smiley
Should work fine.

The trickiest part is the file system.
If you want it user friendly, you need to create files and obey the rules of FAT16 at least.
Basically only Linux users would be able to use it if you did raw reading and writing.
Logged

Huntsville, AL, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was thinking of writing the raw data with the Arduino as well. If you used it for data an Arduino program could read the card back and write the data serially, right?

Of course, supporting a file system would be even better, but I was thinking of keeping it simple.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried it once. There must be a topic somewhere here. But I lost my patience before it worked. If it works it will be without filesystem though. I switched to dataflash. (memory from atmel). But that is something you can only use with arduino, you can't take the memory out and put it in a pc.

There is someone here, Nick, who got the vinculum working. With that you have an USB interface which you can use with a memory stick, that is even better. He wanted to post it in the playground but I guess he didn't have time yet to do it.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok lets make a deal. You get the SD card working, I'll make a dodgy and small FAT implementation. ;D

I've got a 16mb SD card which I can use.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bingo. The work has already been done for us. smiley

http://www.captain.at/electronic-atmega-mmc.php

Now to convert that for use on the Arduino....
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Bingo. The work has already been done for us. smiley

http://www.captain.at/electronic-atmega-mmc.php

Now to convert that for use on the Arduino....

Seems easy doesn't it? good luck!
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I've wired up my floppy drive SD card socket (damn. I didn't realize I still had so many of them) and I've realized that I don't have a multimeter to test it. smiley-sad
I'll go buy one tomorrow hopefully.

Until then, I'm going to be praying that this works. smiley
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My soldering sucks. ;D

Going to have to buy some pin headers and heat shrink tubing tomorrow as well.
I cant get the tinned wires to stick in the Arduino's ports.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will learn eventually.

Solder some legs from a LED or something to your flatcable, then you can insert it in the headers. When you go out shopping, buy a lot of headers pins. Very handy, especially for flatcable.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You will learn eventually.
I know how to solder. I just haven't done it in about a year. smiley
I'm primarily a programmer.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I'm looking at someone else's code which uses a lot of this:
Code:
   /* initialize SPI with lowest frequency; max. 400kHz during identification mode of card */
    SPCR = (0 << SPIE) | /* SPI Interrupt Enable */
           (1 << SPE)  | /* SPI Enable */
           (0 << DORD) | /* Data Order: MSB first */
           (1 << MSTR) | /* Master mode */
           (0 << CPOL) | /* Clock Polarity: SCK low when idle */
           (0 << CPHA) | /* Clock Phase: sample on rising SCK edge */
           (1 << SPR1) | /* Clock Frequency: f_OSC / 128 */
           (1 << SPR0);
    SPSR &= ~(1 << SPI2X); /* No doubled clock frequency */
Does anyone know of a good reference for this stuff?

Once I know how to convert it to Arduino style code, I should be dumping data from a SD card. smiley
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi cheater,

take a look here: http://www.arduino.cc/en/Reference/Bitshift

good luck!
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Ok I'm looking at someone else's code

Once I know how to convert it to Arduino style code, I should be dumping data from a SD card. smiley

Absolutely!  smiley-grin This is what I used:
Code:
 SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0)|0<<SPI2X;
But remember: I didn't get it working before I lost my patience with it.
« Last Edit: September 23, 2007, 09:04:55 am by bigengineer » Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Should have made myself clearer.

I need help with the letters, not the bit shifting. smiley
E.g. SPCR, SPE, etc...
Logged

Pages: [1] 2 3   Go Up
Jump to: