SD Card Example Code
I have been attempting for the past week to get the SX48 to interface with an SD card. After trying to follow many different (and often contradicting) specs for SD cards, and trying multiple different brands of SD cards, I've come to the conclusion I must be missing something. Does anyone have any sample code for the SX48 (or something similar enough where porting would be straight forward) that can read data from an SD card? Writing isn't important for what I'm trying to do. The only sample code I have been able to find is for other microcontrollers that have a built in SPI interface, which doesn't help in any way, because I think the problem is with my implementation of the SPI interface.
Any help would be greatly appreciated, or a purposed alternative to easily (and cheaply, I don't have $70 to spare
) storing about 1MB of data to be accessed from an SX48.
Any help would be greatly appreciated, or a purposed alternative to easily (and cheaply, I don't have $70 to spare
![cry.gif](http://forums.parallax.com/images/smilies/cry.gif)
Comments
· If you post what code you have so far, I'm sure we can help you. If you only need to read, that shouldn't be too hard. As long as you are using FAT16 and NOT using long file names.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
My queue looks like this:
'Typical Queue
' |O| |1| |A| |/|t|.|g|<|W| |1| |xx|xx|<|xx|xx|xx|xx|,|xx|xx|;|C| |1|<|
' | open command | write command |tick and data |close command
The Open command is simply O, the file handle, and A for append. This is followed by the name of the file. I use short file names to shorten the communication time. The next command, W, writes the data to the file handle. The write command must know the number of bytes to write. Once the write command is sent, the SD Module expect to receive the exact number of bytes you told it in the write command. The last command is C for close, and the file handle.
Once the queue is set up, the commands to communicate become pretty simple. I use SEROUT and SERIN.
SDMWrite uses SDMWriteSupport to write each byte, and UpdateIndex to march through the queue. At the end of each command, the SD Module returns a carriage return as a prompt. SDMWrite uses SDMRead to watch for the prompt.
Joe