2020-12-03 09:02 AM
Hello everyone,
My company bought a card ... We want to use the 4 bit SD card.
I generated a System Workbench for STM32 project (FatFs) , without modifying anything in the GPIO, SDMMC or other properties.
Compilation and programming is done without problem.
However when I debug, the initialization part of the SD card shows an error.
The source of this error is as follows:
Stm32h7xx_ll_sdmmc.c file
Line: 1240 - 1254
/**
* @brief Checks for error conditions for R1 response.
* @param hsd: SD handle
* @param SD_CMD: The sent command index
* @retval SD Card error state
*/
static uint32_t SDMMC_GetCmdResp1(SDMMC_TypeDef *SDMMCx, uint8_t SD_CMD, uint32_t Timeout)
{
uint32_t response_r1;
uint32_t sta_reg;
/* 8 is the number of required instructions cycles for the below loop statement.
The Timeout is expressed in ms */
uint32_t count = Timeout * (SystemCoreClock / 8U /1000U);
do
{
if (count-- == 0U)
{
return SDMMC_ERROR_TIMEOUT;
}
sta_reg = SDMMCx->STA;
}while(((sta_reg & (SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CMDREND | SDMMC_FLAG_CTIMEOUT | SDMMC_FLAG_BUSYD0END)) == 0U) ||
((sta_reg & SDMMC_FLAG_CMDACT) != 0U ));
if(__SDMMC_GET_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT))
{
__SDMMC_CLEAR_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT);
return SDMMC_ERROR_CMD_RSP_TIMEOUT;
}
The error flag is: SDMMC_FLAG_CTIMEOUT
when:
sta_reg = SDMMCx-> STA; (line 1246)
Another noteworthy fact, when we first tried the evaluation board, the demo with the screen remaining "black" (but we could see that the screen was backlit)
Tests:
I tried several sd cards greater than 8 giga.
The power supply is made with the 220V - 5V power supply
I also tried with the power supply via the ST-link.
If I remove the SD card, the result is the same (same timeout error)
The power supply to the card is indeed 2.9V. Tested on SD port and TP9 pinout.
Could you tell me if this is a configuration problem? where Hardware?
Files
The main file :
2020-12-04 05:51 AM
For information, I think I found the error.
The clock frequency at initialization is 400 Khz.
However, the frequency for the CMD line is 500 Mhz.
I think the frequency of the CMD line should also be 400 Khz.
But how to change this frequency for the CMD line?
2020-12-04 06:45 AM
Solution found, TranceiverPresent been on SDMMC_TRANSCEIVER_NOT_PRESENT
Set now at SDMMC_TRANSCEIVER_PRESENT
2024-08-28 09:46 AM
This worked for me too, you saved my day buddy, THANKS