Matt
Thanks for your feedback.
Regarding the points you make you start by asking "I think the question is for me, what is wrong with the current setup"
From my experience absolutely nothing wrong! As I said at the beginning of this post I have used your code with success and do not wish to find fault. I only to wish to clarify things I do not understand about workings of the SD card specification.
Actually I was very surprised and pleased when I bought an SD card reader, wired it up according to your tutorial notes, used your SD card example and library and the thing worked first time. This gave me the encouragement to try to understand how SD card works and how your code achieves this. So thanks again for your effort.
One point you make in your last post is:-
"2) It will fix a card that that is powered up and in the middle of a read or write......."
You are of course correct.
This would fall under state 8) of the conditions I mentioned in my post namely
8) Card in SPI bus mode - busy state.
I had missed the possible need to get a card out of busy mode under certain conditions that you mention, concentrating only on the card under power up or idle states.
I understand and accept your comment.
In a later comment you say "I don't think the only reason for CMD1 is init". This is an interesting point because
I too do not really understand what the full implications of the results of each command (assuming they are accepted and executed by the card) really are.
The SAN DISK documentation command table only vaguely refers to CMD1 "initializes the card" but what exactly does this mean?
Elsewhere the documentation seems to imply that the end result of a CMD1 command execution is to place the card in "ready to receive further commands" mode.
This is why I queried the use of CMD1 in your sd_set_idle procedure after issuing a CMD0 to request the idle state. Since to obtain and query a card response using CMD1, in order to check that the card had entered idle state would in fact bring it OUT of the idle state (if it had got there) and make it ready. As I understand it using CMD13 would let us check the card status register to establish that the card had in fact entered idle state but without causing a state change itself.
The card state should not change as a result of issuing a CMD13. Hope this makes sense.
Kind Regards
Dave Paxton
Okay, What would be a worthwhile contribution?
Mike