Hello,
I am using the Arduino SD library and I was having an inconsistent response with some SD card modules - some of the SD cards failed to initialize (with SD.begin()) despite having the same hardware (same module, same SD card). I'm using SanDisk UHS-1 cards which, according to the OEM product manual support the voltage range 2.7-3.3V.
When I hooked it up to a scope and logic analyzer, I found a very, very slight variation in output voltage from the SPI MISO line which is enough to not trigger my MCU - sometimes as low as 1.58V. The problem here is that the SD cards are outputting in 1.8V mode. So I want to put these cards into a higher voltage mode, so that they will output 3.3V but I am having trouble setting this in the SD library.
The SD protocol shows the initialization for CMD8 that I have attached here. It says bits [19:16] are the supplied voltage setting in the issued command. But when I try to issue 0x101AA instead of 0x1AA, the initialization fails. The R7 response still shows an undefined value for 'Voltage Accepted'. Even a further reading of the OCR register continues to return an undefined value for voltage mode.
OK, so CMD8 is only to show you what the card status is. Apparently, the mode can be set during ACMD41.
The protocol says:
(1) If the voltage window field (bit 23-0) in the argument is set to zero, it is called "inquiry CMD41" that does not start initialization and is use for getting OCR. The inquiry ACMD41 shall ignore the other
field (bit 31-24) in the argument.
(2) If the voltage window field (bit 23-0) in the argument is set to non-zero at the first time, it is called "first ACMD41" that starts initialization. The other field (bit 31-24) in the argument is effective.
The cards I am using are type SD2.
arg = type() == SD_CARD_TYPE_SD2 ? 0X40000000 : 0;
while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) {...}
But according to the protocol, would this have any effect if the lower bits 23-0 are still set to 0?
Furthermore, the cardCommand() function sends a 32-bit argument, but are the bits in the right place here? What should be sent instead to ensure that the card does not switch to 1.8V but instead stays in current signal voltage mode?