2010-09-02 06:48 AM
MMC Write error
2011-05-17 05:05 AM
None???
I attach the file sdcard.c that I have changed to read the MMC. What is wrong?Just run the demo with replacing this file.
Thanx2011-05-17 05:05 AM
i have found my error...is the freq of SDIO......
now i have new problem....i can't set high-speed....i use this command.. /* SEND CMD16 to set hi-speed */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) 0x3B90100; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_HS_SWITCH; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_HS_SWITCH); it right?? the mmc return ok, but if i set freq over 20Mhz i have a crc error..... tanks all...2011-05-17 05:05 AM
You mention you're using eMMC so your memory should go to at least 26MHz but only after the SWITCH to high-speed succeeds.
Try sending the SEND_EXT_CSD command before and after the SWITCH to high speed. You should see the HS_TIMING byte (index 0xB9) change from 0 to 1. If the switch works the HS_TIMING should be 1 the second time you read the results from EXT_CSD. The other possibility is that the controller on the eMMC is buggy. Which part are you using?2011-05-17 05:05 AM
first..tx for replay...
i use eMMC of Micon: MTFC4GDKDQ series. about Send_ext_csd: i send CMD but eMMC dont send ext csd....i only send CMD e wait the data packet....but this is not sent.... must do something first.... Set the block length?If it appears all is ok the problem is to search in the hardware?
And why if imposed 8b band_width at 18 MHz I have data all wrong? To 4b and 1b works perfectly. tnx for patience...2011-05-17 05:05 AM
about send_ext_csd i have found solution....this is code:
/** * @brief Read Ext_CSD. * @param readbuff: pointer to the buffer that will contain the * Ext_CSD data * @param BlockSize: the SD card Data block size. * @retval SD_Error: SD Card Error code. */ SD_Error SD_Read_Hex_Csd(uint32_t *readbuff, uint16_t BlockSize) { SD_Error errorstatus = SD_OK; uint32_t *tempbuff = readbuff, count = 0; SDIO_CmdInitStructure.SDIO_Argument = BlockSize; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_SET_BLOCKLEN; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_SET_BLOCKLEN); if (errorstatus != SD_OK) { return(errorstatus); } SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; SDIO_DataInitStructure.SDIO_DataLength = (uint32_t) BlockSize; SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 0x90; 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); /* SEND CMD8 to recive ext-CSD */ SDIO_CmdInitStructure.SDIO_Argument = 0x00; SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_HS_SEND_EXT_CSD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SDIO_HS_SEND_EXT_CSD); if (errorstatus != SD_OK) { return(errorstatus); } /* 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 < 8; count++) { *(tempbuff + count) = SDIO_ReadData(); } tempbuff += 8; } } if (SDIO_GetFlagStatus(SDIO_FLAG_DTIMEOUT) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DTIMEOUT); errorstatus = SD_DATA_TIMEOUT; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL) != RESET) { SDIO_ClearFlag(SDIO_FLAG_DCRCFAIL); errorstatus = SD_DATA_CRC_FAIL; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_RXOVERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_RXOVERR); errorstatus = SD_RX_OVERRUN; return(errorstatus); } else if (SDIO_GetFlagStatus(SDIO_FLAG_STBITERR) != RESET) { SDIO_ClearFlag(SDIO_FLAG_STBITERR); errorstatus = SD_START_BIT_ERR; return(errorstatus); } while (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *tempbuff = SDIO_ReadData(); tempbuff++; } /* Clear all the static flags */ SDIO_ClearFlag(SDIO_STATIC_FLAGS); return(errorstatus); } i verify the Hs_timing....i set correctly but if i set clock over 20 Mhz it dont work.... also if i se 8bit band width i receve all wrong data.... thx...2011-05-17 05:05 AM
Regarding the 8bit problems - maybe you have signal integrity issues? If it works ok with the narrower bus there's probably no problem with your code but there might be crosstalk or the timing of some of the lines relative to the clock could be marginal. My Micron eMMC works fine at 8 bit but I only run it at very slow speeds (1 or 2 MHz).
Does your 8 bit mode work up to a certain frequency and then fail? Or does it fail at any frequency? I haven't yet tested the STM32 SDIO peripheral in 8 bit mode but will do that soon. If I find a similar problem with 8 bit I'll post it here. I think you may be looking at two distinct problems: 8 bit problem could be electrical or a problem with the SDIO peripheral. The HS timing could be on the eMMC side since the problems occur at 20MHz and that's the cutoff of the old MMC spec. The errata for the Micron part mention that the CSD register has the incorrect value of 20MHz for the max speed but it doesn't say whether that affects the operation of the controller or whether it's just a wrong value in the register.2011-05-17 05:05 AM
No...8b not work at all freq.....i have try at 400 Hz.
i will try to re-build circuit...... thx.2011-05-17 05:05 AM
Just to follow up on this: 8bit eMMC writes are working now but I cannot run at full speed (clock divider 1) or I get TX FIFO underrun. It works fine around 18MHz.
Andrew2011-05-17 05:05 AM
Hi Andrew...
for go over 20 Mhz you do first set HS_Timing on ext_csd of eMMC...Still I am unable to solve my problem..... you could attach files about the management of emmc? So I can compare them with my, to find the error that I. I thank you!!!