I'm writing a BSP for an SD Card driver, and encountered an issue which is preventing me from reading data from the SD Card.
The SD Card driver is attempting to read the SCR from the card using CMD51. The driver indicates to my BSP that this is a read command, so my command setup is trying to set the DDIR bit in SD_CMD to indicate a read. (This bit reads back as zero after being "set", but bits 16 - 23 of the register read back properly)
The command transmits successfully, then the card driver calls my "read data" entry point, but at this point the SD_PSTATE register has WTA (Write Transfer Active) and BWE (Buffer Write Enable) set, instead of the expected RTA (Read Transfer Active) and BRE (Buffer Read Enable). This is presumably due to the DDIR bit not being set to 1.
I've tried accessing the transfer mode bits in SD_CMD as a separate 16-bit or 8-bit value, and changing the order of the accesses to the transfer mode bits and the "type" bits, but I'm still getting readback values that seem to indicate the controller is treating this command as a write instead of a read.
What do I need to do to get the DDIR data direction bit set properly, so that my "read" command is treated as a read operation?