I'm trying to get SD writing working, with some limited success.
It appears I can write one block successfully, but when I try to write a second block, after sending the second WRITE_SINGLE command I don't see a CMD_DONE interrupt, instead I get a DATA_TIMEOUT interrupt. At this point registers are:
Status: 0x01ef0107 (indicates DAT_ACTIVE/DAT_INHIBIT)
Resp: 0x00000900 (may be the value from the previous write command)
Interrupt: 0x00108000 (indicates DATA_TIMEOUT)
All I can think is that for some reason the previous block write has not completed, although as far as I can see the data is completely written and there on the card as expected.
Do I need to wait for the DAT_INHIBIT flag to drop from the status register before sending another WRITE_SINGLE command? I checked on entry to the second call and status before the command is 0x01ef0006, indicating DAT_ACTIVE|DAT_INHIBIT.
Here's how I do the data transfer (somewhat reduced):
*EMMC_BLKSIZECNT = (1 << 16) | 512;
// sendCommand waits for CMD_DONE interrupt;
// command value being sent is actually:
// 0x18000000|CMD_RSPNS_48 |CMD_IS_DATA|TM_DAT_DIR_HC
sdSendCommand(WRITE_SINGLE,blockAddress);
while( numWritten < 128 ) {
if( *EMMC_STATUS & SR_WRITE_AVAILABLE )
*EMMC_DATA = buffer[numWritten++];
else
waitCycle(150);
}
Thanks, Simon