cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F207VC SDIO and Fatfs Problem

e_j_g
Associate II
Posted on July 11, 2016 at 11:27

Hi All

I am Using STM32F207VC And Micro SD Card With SDIO Interface And Fatfs Library

When I Debug And Trace Code, SDIO Routine Response This Error:

 

/*!< Card is not V2.0 complient or card does not support the set voltage range */

What Is Mean?

What Do I Do For debug This Error?

#fatfs #sdio #sdio #stm32f207 #dma-config-for-sdio
11 REPLIES 11
Posted on July 11, 2016 at 14:09

Describe the specific card (make, model, capacity, etc) you are having problems with. Are other cards working? Is the interface wired correctly? What board is this?

Make sure the SDSTATUS_Tab has 64 elements.

The error seems to suggest the card is non-responsive

Test the code/card on known working hardware.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
e_j_g
Associate II
Posted on July 11, 2016 at 14:53

hi clive And Tanks For Response

I Read A

Article

?About SDIO Interface

http://blog.frankvh.com/2011/09/04/stm32f2xx-sdio-sd-card-interface/

That Write About Hardware That must Use A Buffer For SDIO Voltage

My Board Dont Have Any Buffer And Connect MicroSD Driectly To STM32F207VC

Is There Any Issuse For This Problem?

0690X000006039tQAA.jpg

Posted on July 11, 2016 at 21:47

I have my card detect with a pull-up, the socket grounds the pin.

You'd need to make sure you use external pull-ups on the data, and command pins, or configure them with pull-ups. This configuration works for an assortment of F2 and F4 boards.

void SD_LowLevel_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOC and GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SDIO);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_SDIO);
/* Configure PC.08, PC.09, PC.10, PC.11 pins: D0, D1, D2, D3 pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Configure PD.02 CMD line */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Configure PC.12 pin: CLK pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
/* Enable the SDIO APB2 Clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SDIO, ENABLE);
/* Enable the DMA2 Clock */
RCC_AHB1PeriphClockCmd(SD_SDIO_DMA_CLK, ENABLE);
}

The SDIO requires the PLL to be clocking to function. A board running at 2.7 - 3.3V shouldn't require any voltage adjustment. I'll assume no cards are working..
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
e_j_g
Associate II
Posted on July 12, 2016 at 08:32

Hi Clive

That's Great And My Problem

Solved

!

But I Have A New Problem With DMA Config Now!

The DMA Flag Dos Not Set And Stay Reset

I Think The SDIO Routine Not Configure Correctly

Because I Ported STM32F10X SDIO Routine To My Project.

I Attached SDIO Routine File.

Please Help Me

Tanks Very Very Much

________________

Attachments :

sdio_sd.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Ja&d=%2Fa%2F0X0000000beG%2F39c6D4aF8Wj9_1u35QlaceV7JHtaLxmZ1mvfwqKxwtY&asPdf=false

sdio_sd.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0pu&d=%2Fa%2F0X0000000beF%2FqsvUs3V2GoY8g3teMhMYkgM1pSzr3poEZRMnCCLK_gs&asPdf=false
Posted on July 13, 2016 at 11:31

The DMA initialization structure needs to specify channel.

DMA Flags need to end in stream number, ie TCIF3.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
e_j_g
Associate II
Posted on July 16, 2016 at 10:43

Hi Dear Clive

I Very Tried To Run This Project But SDIO Routine Run In This While Loop:

while ((SD_DMAEndOfTransferStatus() == RESET) && (TransferEnd == 0) && (TransferError == SD_OK))

this Is My DMA Config In Project in SDIO.c File:

void SD_LowLevel_DMA_RxConfig(uint32_t *BufferDST, uint32_t BufferSize)
 {
 DMA_InitTypeDef DMA_InitStructure;
 DMA_ClearFlag(DMA2_Stream3,DMA_FLAG_TCIF3 | DMA_FLAG_TEIF3 | DMA_FLAG_HTIF3 | DMA_FLAG_DMEIF3 | DMA_FLAG_FEIF3);
 //DMA_ClearFlag(DMA2, SD_SDIO_DMA_FLAG_FEIF | SD_SDIO_DMA_FLAG_DMEIF | SD_SDIO_DMA_FLAG_TEIF | SD_SDIO_DMA_FLAG_HTIF | SD_SDIO_DMA_FLAG_TCIF);
 
 /*!< DMA2 Channel4 disable */
 //DMA_Cmd(DMA2_Channel4, DISABLE);
 DMA_Cmd(DMA2_Stream3, DISABLE);
 
 /*!< DMA2 Channel4 Config */
 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SDIO_FIFO_ADDRESS;
 DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferDST;
 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
 DMA_InitStructure.DMA_BufferSize = BufferSize / 4;
 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
 DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
 DMA_InitStructure.DMA_Priority = DMA_Priority_High;
 //DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
 DMA_Init(DMA2_Stream3, &DMA_InitStructure);
 /*!< DMA2 Channel4 enable */
 DMA_Cmd(DMA2_Stream3, ENABLE); 
 }
 /**
 * @brief Configures the DMA2 Channel4 for SDIO Tx request.
 * @param BufferSRC: pointer to the source buffer
 * @param BufferSize: buffer size
 * @retval None
 */
 void SD_LowLevel_DMA_TxConfig(uint32_t *BufferSRC, uint32_t BufferSize)
 {
 DMA_InitTypeDef DMA_InitStructure;
 //DMA_ClearFlag(DMA2_FLAG_TC4 | DMA2_FLAG_TE4 | DMA2_FLAG_HT4 | DMA2_FLAG_GL4);
 DMA_ClearFlag(DMA2_Stream3,DMA_FLAG_TCIF3 | DMA_FLAG_TEIF3 | DMA_FLAG_HTIF3 | DMA_FLAG_DMEIF3 | DMA_FLAG_FEIF3);
 /*!< DMA2 Channel4 disable */
 DMA_Cmd(DMA2_Stream3, DISABLE);
 /*!< DMA2 Channel4 Config */
 DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SDIO_FIFO_ADDRESS;
 DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferSRC;
 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
 DMA_InitStructure.DMA_BufferSize = BufferSize / 4;
 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
 DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
 DMA_InitStructure.DMA_Priority = DMA_Priority_High;
 //DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
 DMA_Init(DMA2_Stream3, &DMA_InitStructure);
 /*!< DMA2 Channel4 enable */
 DMA_Cmd(DMA2_Stream3, ENABLE); 
 }

Posted on July 16, 2016 at 16:52

  DMA_InitStructure.DMA_Channel = DMA_Channel_4; // Must specify a channel in the initialization structure

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
e_j_g
Associate II
Posted on July 16, 2016 at 17:44

Tanks Clive

that's Right and Other Problem Was The DMA Must Be Enable Before Clear Flags

I Corrects All Things And Now I Receive FR_NO_FILESYSTEM Response In f_open Function

when I Trace And Debug Code :

The Disk_read() Response SD_OK

The check_fs() Response 2 => /* No FAT volume is found */

e_j_g
Associate II
Posted on July 19, 2016 at 16:05

Is There Any Body For Ask My Question?

When I Debug Project I Receive FR_NO_FILESYSTEM Response In F_Open Function

when Trace Project Routine The check_fs() Function  Response ''2'' and Then Response FR_NO_FILESYSTEM    

/* No FAT volume is found */

Tanks All