cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO + DMA + CRC

tobias239955
Associate II
Posted on September 06, 2012 at 10:49

ello,

I sometimes have problems with blocks which are written completely wrong onto the sd-card. Workaround: actually I check the written data again by reading the same block from SD-card and check the both buffers if they are equal. Now I have problems to get the CRC-check working on my STM32F103 controller. Here is a small dummy-routine:

/*!< Send CMD24 WRITE_SINGLE_BLOCK */

SDIO_CmdInitStructure.SDIO_Argument = WriteAddr;

SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_WRITE_SINGLE_BLOCK;

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);

/* Set the BlockSize and so on */

SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT;

SDIO_DataInitStructure.SDIO_DataLength = BlockSize;

SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4;

SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard;

SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block;

SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;

SDIO_DataConfig(&SDIO_DataInitStructure);

/* Start DMA transfer */

SDIO_ITConfig(SDIO_IT_CTIMEOUT | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_TXUNDERR | SDIO_IT_RXOVERR | SDIO_IT_DCRCFAIL | SDIO_IT_CCRCFAIL, ENABLE);

SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize + sizeof(uint16));

SDIO_DMACmd(ENABLE);

So, I transfer one datablock (512 bytes) + a uint16 with containing a dummy-CRC value.

I think this should result in a CRC error, because the dummy CRC value is not correct? But I will get no CRC-error. Do I have to activate the CRC check manually?

The manual says:

“During block write (CMD24 - 27) one or more blocks of data are transferred from the host to

the card with a CRC appended to the end of each block by the host. A card supporting block

write is always able to accept a block of data defined by WRITE_BL_LEN. If the CRC fails,

the card indicates the failure on the SDIO_D line and the transferred data are discarded and

not written, and all further transmitted blocks (in multiple block write mode) are ignored.�

In WaitWriteOperation() I check:

if(SDIO_GetFlagStatus(SDIO_FLAG_CCRCFAIL) || (SDIO_GetFlagStatus(SDIO_FLAG_DCRCFAIL)))

{

         TransferError = SD_ERROR;

}

And also the Interrupts SDIO_IT_DCRCFAIL | SDIO_IT_CCRCFAIL will not fire.

What´s wrong here?

0 REPLIES 0