2013-02-01 07:03 AM
I'm trying to read the SD CARD Configuration Register (SCR) on an SD memory card using the SDIO peripheral and I'm not sure if I'm approaching this in the right way, so I'm hoping someone here may have some experience with this.
This register is 64-bits wide, and appears to be read using a normal 'data read' operation, except that normally data is read in a standard block size (512-bytes).If I try to read only 9 bytes (8 data plus 1 CRC), I get an error (the block read throws errors such as CRC failed, etc) and the data FIFO buffer appears to corrupt (all 32-bit words change to the same value).Is there a special way I am meant to configure the Data Path State Machine in order to read this register without causing errors.2014-01-30 12:30 AM
rowan have you solved
?There is a
ST
examplethat
explains how to read
the SCR
But I think it
is only
for
SD cards
For HC
or
XC
the memory access
isblock
not
bytes
and
this
confuses me
. Thisalso applies to
the SDIO_SD_APP_SEND_SCR command
?2014-02-10 07:44 AM
This work for me tested with SD 1GB and SDHC 4GB
SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;
SDIO_DataInitStructure.SDIO_DataLength = 8;
SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_8b;
SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO;
SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block;
SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
SDIO_DataConfig(&SDIO_DataInitStructure);
SD_send_command (SDIO_SD_APP_SEND_SCR, 0x00000000, SDIO_Response_Short, SDIO_Wait_No);
sd.opstate = SD_OP_DATABUSCFG04 ;
case SD_OP_DATABUSCFG04:
if (!SD_Cmdreply(SDIO_SD_APP_SEND_SCR, true)) break ;
sd.opstate = SD_OP_DATABUSCFGEND;
if (sd.error != SD_OK) break ;
index = 0 ;
sd.opstate = SD_OP_DATABUSCFG05 ;
case SD_OP_DATABUSCFG05:
while (!(SDIO->STA &(SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR)))
{
if (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET)
{
if (index == 0)
{
SCRrawH = SDIO_ReadData() ;
}
else if (index == 1)
{
SCRrawL = SDIO_ReadData() ;
}
else
{
SDIO_ReadData() ;
}
index++ ;
}
}