I've had a goal to at least attempt some PICAXE-SD card communications for some time now and after looking at some previous attempts (acknowledgements to Hippy and DPG) and despite the problems most people seem to have had, I decided to have a shot at it anyway since I have some time during my Uni break.
To that end, I managed to use a PICAXE-28X1 to do some simple initialisation, reading and writing to a small range of different SD cards (I have a 16MB Canon, 128MB Generic, 256MB Sandisk, 1GB Sandisk Ultra II, 2GB Sandisk Ultra II Plus and 2GB Generic). So far, the results have been promising in that I have successfully managed to initialise all the cards except for the 2GB cards and I had and managed to write a 512 byte sector to each of them, neglecting anything to do with any sort of file-system: FATxx etc. These results were confirmed using a SD card reader and appropriate software on my desktop computer.
I did run into a couple of problems that I've not yet had the time to fully investigate and could do with some suggestions. Before I do that, I'll just give a quick background of my setup:
The cards are socketed into a breadboard and connected via SPI to the PICAXE (28X1, FW.A0) with 100k pull-up resistors (I've also tried 47k and 82k). Both the card and PICAXE are powered from a regulated 3.3V supply with 100uF bulk capacitance and two 0.1uF capacitors near the SD card's power pins and one near the PICAXE's supply pins. I've run all my tests using both 4MHz and 8MHz internal oscillators as well as 4MHz and 16MHz external resonators (with the appropriate setfreq commands). Operations always used spislow mode but all results were also reproducible if spimedium was used after initialisation.
To the "problems" at hand:
1) Why could I not initialise the 2GB cards? Perhaps of relavance, I assume that both of them are not SDHC cards as I use both of them in my PDA which I do not believe supports SDHC cards.
2) As mentioned, spimedium worked if switched to after the cards were initialised (i.e. when I begin my read/write tests). spifast was strictly no-go with the PICAXE timing out after ~2.3 seconds and resetting itself. Why?
Interestingly, I couldn't get spifast to work with my SPI interfaced MP3 decoder chip (VLSI VS1002D) either, but spislow and spimedium worked fine...
3) Although the data was successfully written to all the cards which could be initialised, I have had problems reading the data back from only the 16MB Canon; all the other cards report the correct data back. Regardless of the data stored, the data received turns to:
xx xx xx xF FF xx xx xx xx xx xx xF FF xx xx xx ...
Just to clarify, the first three bytes are read correctly (the first three sets of "xx". The upper (4-bit) nibble of the next byte is received correctly then 12 high bits are received (thus three hexadecimal digits of "FFF"). The cycle then repeats with a period of 8 bytes with the rest of the bits until the next cycle read/reported correctly.
As I said, this only occurs with only ONE of my SD card while all the others report the data back perfectly. First thing that comes to mind is some "card not to specification" thing, but the periodicity and reproducibility makes me wonder.
Anyhow, any and all suggestions to the above points are appreciated in advance and will be entertained as time permits. Thanks!
ylp88
To that end, I managed to use a PICAXE-28X1 to do some simple initialisation, reading and writing to a small range of different SD cards (I have a 16MB Canon, 128MB Generic, 256MB Sandisk, 1GB Sandisk Ultra II, 2GB Sandisk Ultra II Plus and 2GB Generic). So far, the results have been promising in that I have successfully managed to initialise all the cards except for the 2GB cards and I had and managed to write a 512 byte sector to each of them, neglecting anything to do with any sort of file-system: FATxx etc. These results were confirmed using a SD card reader and appropriate software on my desktop computer.
I did run into a couple of problems that I've not yet had the time to fully investigate and could do with some suggestions. Before I do that, I'll just give a quick background of my setup:
The cards are socketed into a breadboard and connected via SPI to the PICAXE (28X1, FW.A0) with 100k pull-up resistors (I've also tried 47k and 82k). Both the card and PICAXE are powered from a regulated 3.3V supply with 100uF bulk capacitance and two 0.1uF capacitors near the SD card's power pins and one near the PICAXE's supply pins. I've run all my tests using both 4MHz and 8MHz internal oscillators as well as 4MHz and 16MHz external resonators (with the appropriate setfreq commands). Operations always used spislow mode but all results were also reproducible if spimedium was used after initialisation.
To the "problems" at hand:
1) Why could I not initialise the 2GB cards? Perhaps of relavance, I assume that both of them are not SDHC cards as I use both of them in my PDA which I do not believe supports SDHC cards.
2) As mentioned, spimedium worked if switched to after the cards were initialised (i.e. when I begin my read/write tests). spifast was strictly no-go with the PICAXE timing out after ~2.3 seconds and resetting itself. Why?
Interestingly, I couldn't get spifast to work with my SPI interfaced MP3 decoder chip (VLSI VS1002D) either, but spislow and spimedium worked fine...
3) Although the data was successfully written to all the cards which could be initialised, I have had problems reading the data back from only the 16MB Canon; all the other cards report the correct data back. Regardless of the data stored, the data received turns to:
xx xx xx xF FF xx xx xx xx xx xx xF FF xx xx xx ...
Just to clarify, the first three bytes are read correctly (the first three sets of "xx". The upper (4-bit) nibble of the next byte is received correctly then 12 high bits are received (thus three hexadecimal digits of "FFF"). The cycle then repeats with a period of 8 bytes with the rest of the bits until the next cycle read/reported correctly.
As I said, this only occurs with only ONE of my SD card while all the others report the data back perfectly. First thing that comes to mind is some "card not to specification" thing, but the periodicity and reproducibility makes me wonder.
Anyhow, any and all suggestions to the above points are appreciated in advance and will be entertained as time permits. Thanks!
ylp88