Go Down

Topic: Reading/Writing SD/MMC Cards Via SDI (Read 2986 times) previous topic - next topic

cmpalmer

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

Cheater

I was thinking of eventually getting around to doing this. :)
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.

cmpalmer

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.

bigengineer

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.

Cheater

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.

Cheater

Bingo. The work has already been done for us. :)

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

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

bigengineer

Quote
Bingo. The work has already been done for us. :)

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

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


Seems easy doesn't it? good luck!

Cheater

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. :(
I'll go buy one tomorrow hopefully.

Until then, I'm going to be praying that this works. :)

Cheater

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.

bigengineer

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.

Cheater

Quote
You will learn eventually.

I know how to solder. I just haven't done it in about a year. :)
I'm primarily a programmer.

Cheater

Ok I'm looking at someone else's code which uses a lot of this:
Code: [Select]
   /* 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. :)

kuuk

hi cheater,

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

good luck!

bigengineer

#13
Sep 23, 2007, 04:04 pm Last Edit: Sep 23, 2007, 04:04 pm by bigengineer Reason: 1
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. :)


Absolutely!  :D This is what I used:
Code: [Select]
 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.

Cheater

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

Should have made myself clearer.

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

Go Up