cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC SD Card read error

AKim.15
Associate II

Hello.

I implement the SD Card access using the SDMMC1 on the NUCLEO-H743ZI board + SD Card sub board.

Now the SDMMC1 Interrupt was not occurred after the DMA request setting and SDMMC interrupt enable(DCRC, TIMEOUT, RXOVERR, DATAEND) for reading the MBR block of the SD Card.

The SDMMC global interrupt is enabled initially.

I have checked the SDMMC Data signal.

I found the valid data signal at the initialization time for the SDMMC operation.

But there is not any data signal after DMA request and SDMMC interrupt enable setting.

HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd,
                                        uint32_t NumberOfBlocks)
{
  SDMMC_DataInitTypeDef config;
  uint32_t errorstate;
  uint32_t add = BlockAdd;
 
  if (NULL == pData)
  {
    hsd->ErrorCode |= HAL_SD_ERROR_PARAM;
    return HAL_ERROR;
  }
 
  if (hsd->State == HAL_SD_STATE_READY)
  {
    hsd->ErrorCode = HAL_SD_ERROR_NONE;
 
    if ((add + NumberOfBlocks) > (hsd->SdCard.LogBlockNbr))
    {
      hsd->ErrorCode |= HAL_SD_ERROR_ADDR_OUT_OF_RANGE;
      return HAL_ERROR;
    }
 
    hsd->State = HAL_SD_STATE_BUSY;
 
    /* Initialize data control register */
    hsd->Instance->DCTRL = 0U;
 
    hsd->pRxBuffPtr = pData;
    hsd->RxXferSize = BLOCKSIZE * NumberOfBlocks;
 
    if (hsd->SdCard.CardType != CARD_SDHC_SDXC)
    {
      add *= 512U;
    }
 
    /* Configure the SD DPSM (Data Path State Machine) */
    config.DataTimeOut   = SDMMC_DATATIMEOUT;
    config.DataLength    = BLOCKSIZE * NumberOfBlocks;
    config.DataBlockSize = SDMMC_DATABLOCK_SIZE_512B;
    config.TransferDir   = SDMMC_TRANSFER_DIR_TO_SDMMC;
    config.TransferMode  = SDMMC_TRANSFER_MODE_BLOCK;
    config.DPSM          = SDMMC_DPSM_DISABLE;
    (void)SDMMC_ConfigData(hsd->Instance, &config);
 
    __SDMMC_CMDTRANS_ENABLE(hsd->Instance);
    hsd->Instance->IDMABASE0 = (uint32_t) pData ;
    hsd->Instance->IDMACTRL  = SDMMC_ENABLE_IDMA_SINGLE_BUFF;
 
    /* Read Blocks in DMA mode */
    if (NumberOfBlocks > 1U)
    {
      hsd->Context = (SD_CONTEXT_READ_MULTIPLE_BLOCK | SD_CONTEXT_DMA);
 
      /* Read Multi Block command */
      errorstate = SDMMC_CmdReadMultiBlock(hsd->Instance, add);
    }
    else
    {
      hsd->Context = (SD_CONTEXT_READ_SINGLE_BLOCK | SD_CONTEXT_DMA);
 
      /* Read Single Block command */
      errorstate = SDMMC_CmdReadSingleBlock(hsd->Instance, add);
    }
    if (errorstate != HAL_SD_ERROR_NONE)
    {
      /* Clear all the static flags */
      __HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_FLAGS);
      hsd->ErrorCode |= errorstate;
      hsd->State = HAL_SD_STATE_READY;
      hsd->Context = SD_CONTEXT_NONE;
      return HAL_ERROR;
    }
 
    /* Enable transfer interrupts */
    __HAL_SD_ENABLE_IT(hsd, (SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_DATAEND));
 
 
    return HAL_OK;
  }
  else
  {
    return HAL_BUSY;
  }
}

I think that the SDMMC interrupt should be occurred if though any data is not received.

(Because the time out interrupt is enabled.)

Question 1)

If the initialization process of the SD card is passed, the SDMMC Interface is ok.

isn't it?

Question 2)

After the DMA configuration for reading the MBR block in the SD Card, there

isn't any data on the signal line. What should I check for resolving this problem?

Question 3)

If though any data is not received after the DMA configuration, the SDMMC

interrupt must be occurred because of the time out, isn't it?

 I attach the data signal from the initialization to the DMA Read configuration.

0693W00000AM30NQAT.pngThank for your concerning.

2 REPLIES 2
ranciere
Associate III

I have a very similar problem. All of the initialization was okay, but the MBR read (secotr 0) always fail with SDMMC_IT_RXOVERR. Could find a solution?

JHobb.1
Associate

No answer, same issue with MBR.

Ever find a solution?