cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with multiblock SDIO read/write on F1 & F4

infoinfo980
Associate II
Posted on January 03, 2013 at 22:11

Hi everyone,

Whenever I use either of the multiblock read/write functions the peripheral gets stuck in the SD_CARD_SENDING or SD_CARD_RECEIVING state, respectively. Further attempts to access the peripheral in this state are impossible and result in timeouts.

I'm using DMA with SDIO interrupts

The SDIO_IT_DATAEND interrupt fires.

The DMA transfer completes.

The correct data is sent/received.

SDIO_FLAG_RXACT or SDIO_FLAG_TXACT is cleared by the peripheral.

The driver code is based on V1.0.2 of the F4 ST driver. 

It happens on both the F1 and F4.

This only happens for MULTI block commands. I can merrily call the single block commands all day long and the state returns to SD_CARD_TRANSFER after each call.

I'm at a bit of a loss. What's so special about the multiblock commands that could be causing this?

4 REPLIES 4
Posted on January 04, 2013 at 01:54

Is this with an HC or non-HC card?

For non-HC, I'd perhaps look a what block size the card is reporting. Certainly in the single block read you have to do a SET_BLOCKLEN first.

Check perhaps also how large the transfer is:

 SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize;

 
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
infoinfo980
Associate II
Posted on January 04, 2013 at 09:38

Hi Clive,

It's happening on SDHC and non-SDHC. The non-SDHC card is a Sandisk 2Gb Extreme that reports a 2Kb block size. I'll come back with a code snippet shortly. It's odd that I get all the indicators of a successful transfer yet the interface doesn't come out of the transferring state.

- Andy
infoinfo980
Associate II
Posted on January 05, 2013 at 11:31

Here's the code snippet of the read multiblock setup. For clarity error handling has been removed and constants inserted that represent the actual values for block size and address when I call it for a 4Gb SDHC card to read 2 blocks from block index 10000.

SD_Error errorstatus=SD_OK;
SDIO_CmdInitTypeDef cmdInit;
SDIO_DataInitTypeDef dataInit;
/*!< Set Block Size for Card */
cmdInit.SDIO_Argument=512;
cmdInit.SDIO_CmdIndex=SD_CMD_SET_BLOCKLEN;
cmdInit.SDIO_Response=SDIO_Response_Short;
cmdInit.SDIO_Wait=SDIO_Wait_No;
cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
SDIO_SendCommand(&cmdInit);
errorstatus=cmdResp1Error(SD_CMD_SET_BLOCKLEN);
if(SD_OK != errorstatus)
/* error handling snipped */
dataInit.SDIO_DataTimeOut=SD_DATATIMEOUT;
dataInit.SDIO_DataLength=1024;
dataInit.SDIO_DataBlockSize=(uint32_t)9 << 4;
dataInit.SDIO_TransferDir=SDIO_TransferDir_ToSDIO;
dataInit.SDIO_TransferMode=SDIO_TransferMode_Block;
dataInit.SDIO_DPSM=SDIO_DPSM_Enable;
SDIO_DataConfig(&dataInit);
/*!< Send CMD18 READ_MULT_BLOCK with argument data address */
cmdInit.SDIO_Argument=10000;
cmdInit.SDIO_CmdIndex=SD_CMD_READ_MULT_BLOCK;
cmdInit.SDIO_Response=SDIO_Response_Short;
cmdInit.SDIO_Wait=SDIO_Wait_No;
cmdInit.SDIO_CPSM=SDIO_CPSM_Enable;
SDIO_SendCommand(&cmdInit);
errorstatus=cmdResp1Error(SD_CMD_READ_MULT_BLOCK);
if(SD_OK!=errorstatus)
/* error handling snipped */
/* DMA/interrupt config follows immediately here */

neoirto
Associate II
Posted on November 21, 2014 at 13:45

Hi all,

I encounter the exact same problem with multiblock operation. After 2 days debugging, I'm afraid I will need some help to fix that ! After the completion of the firstSD_WriteMultiBlocks() operation, the card is locked for ever in SD_CARD_RECEIVING state when calling a

errorstatus = IsCardProgramming(&cardstate);

I'm working on our new layout for STM32F2, with the Clive version of USB MSC driver + FatFs by Nemuisan. Tx in advance