SPI SD card access
Graham Stabler
Posts: 2,510
I was wondering if there is any code available for SPI access of an SD card, I don't need file transfer from a PC just a load of storage space.
Am I also to understand that one way of getting a some more storage to is to change the EEPROM to a larger model, the first 32k being the program and the rest being free to use. What are the largest EEPROMs available that are suitable?
Cheers,
Graham
Am I also to understand that one way of getting a some more storage to is to change the EEPROM to a larger model, the first 32k being the program and the rest being free to use. What are the largest EEPROMs available that are suitable?
Cheers,
Graham
Comments
It is my understanding that you can put an SD card in SPI mode and just do block writes and reads, basically forget about files alltogether. I actually did this with a PIC and an MMC card, I ended up writing over the FAT so couldn't use it in a PC but I just wanted a massive but cheap store for data. I looked at the commercial boards for SD cards but I want to be able to acess all of the capacity if possible.
Graham
You're right - sector access is independent of any particular filesystem. You could think of the filesystem as a logical layer completely above the sector access layer. I've been experimenting with spin object development by separating those layers.
Here's my latest development code, which has the raw sector access functions separated from filesystem access into separate spin objects. The raw sector access uses a separate assembly cog to speed up the bitwise card operations. All of my access is in SPI mode.
The top object demonstrates accessing raw card sectors as fast as possible, and it demonstrates FAT12 and FAT16 directory listing, displaying filenames and filesizes from the FAT root directory of both MMC and SD cards.
The card and filesystem objects contain several functions not demoed by the top object, but which may be handy - functions that let Spin read or write any address of the separate assembly cog, and a function that reads every sector of a card, counting bad sectors, if any are detected. (I have an old MMC card with some bad sectors).
I haven't gotten as far as writing a sector from the propeller, but from past experience, I don't think it would be too hard.
David
Cheers,
Graham
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
...