2012-02-14 01:20 PM
Hi All,
I have a problem with my MMC card. I try to read the EXT_CSD (512 bytes) with no success. Someone can help me please ? Here below my function. MMC_Error MMC_Get_Ext_CSD ( ) { MMC_Error errorstatus = MMC_OK; int count; SDIO_DataInitStruct.SDIO_DataTimeOut = DataTimeOut; SDIO_DataInitStruct.SDIO_DataLength =512; SDIO_DataInitStruct.SDIO_DataBlockSize = SDIO_DataBlockSize_512b; SDIO_DataInitStruct.SDIO_TransferDir = SDIO_TransferDir_ToSDIO; SDIO_DataInitStruct.SDIO_TransferMode = SDIO_TransferMode_Block; SDIO_DataInitStruct.SDIO_DPSM = SDIO_DPSM_Enable; SDIO_DataConfig(&SDIO_DataInitStruct); SDIO_CmdInitStruct.SDIO_Argument = 0x00; SDIO_CmdInitStruct.SDIO_CmdIndex = CMD8; SDIO_CmdInitStruct.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStruct.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStruct.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStruct); errorstatus = Resp1_Check(CMD8); if (errorstatus != MMC_OK) { return errorstatus ; } eMMC_Delay(5); if (DeviceMode == MMC_POLLING_MODE) { while (!(SDIO->STA &(SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR))) { if (SDIO_GetFlagStatus(SDIO_FLAG_RXFIFOHF) != RESET) { for (count = 0; count < 128; count++) { *(Ext_CSD + count) = SDIO_ReadData(); } } } if (SDIO_GetFlagStatus(SDIO_FLAG_DTIMEOUT) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DTIMEOUT); errorstatus = MMC_DATA_TIMEOUT; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DCRCFAIL); errorstatus = MMC_DATA_CRC_FAIL; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_RXOVERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_RXOVERR); errorstatus = MMC_RX_OVERRUN; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_STBITERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_STBITERR); errorstatus = MMC_START_BIT_ERR; return(errorstatus); } #if 0 /* READ the data available in FIFO */ while (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *tempbuff = SDIO_ReadData(); tempbuff++; } #endif /* Clear all the static flags */ SDIO_ClearFlag(SDIO_FLAGS); } return(errorstatus); }