cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO Wide Bus Enable Issue

lee_trueman
Associate II
Posted on April 11, 2012 at 10:00

In my diskio.c wrapper for fatfs file system i have now got the problem of not been able to enable 4bit wide bus on SDIO. Below is the functions i call in disk_initailse().

errorstatus = SD_Init();

errorstatus = SD_GetCardInfo( &SDCardInfo );

errorstatus = SD_SelectDeselect( (uint32_t)(SDCardInfo.RCA << 16 ));

errorstatus = SD_EnableWideBusOperation( SDIO_BusWide_4b );

If i just run this my code will loop here in FindSCR forever more.

while ( !( SDIO->STA & ( SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL |  SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR)))

    {

        if ( SDIO_GetFlagStatus( SDIO_FLAG_RXDAVL ) != RESET )

        {

            *( tempscr + index ) = SDIO_ReadData();

            index++;

        }

    }

If however i place a break point on SD_Init(), and then single step over the functions one by one, volia !! it works fine, so going slow is the option, i suspect there is some more dodgy code somewhere in the st lib.

Anyone care to comment on this please as this SDIO interface is be coming a pain in the *ss.
7 REPLIES 7
tobias239955
Associate II
Posted on July 13, 2012 at 08:32

Hi Tabulous,

have you already solved this Problem? I´m having exactly the same issue...

My program will loop in this while-construct infinite. This happens not every time, but in 1 of 10 cases... (i re-init the SD-Card if i get a write/read-error)

I found out that this problem does not occur when i reduce the SDIO_TRANSFER_CLOCK to less than 25 MHz. But then my sd-card will be too slow.

Posted on July 13, 2012 at 10:23

I´m having exactly the same issue...

They sound similar, yet I don't know which chip or board combination either of you are using. At least some of the SD_Init() examples do the 4-bit switch within the subroutine itself.

The speed the card runs depends often on the card in question, and how the socket is wired.

Please provide some more details of your specific context.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tobias239955
Associate II
Posted on July 18, 2012 at 07:14

Hi clive,

thank you for your fast reply. I use the

STM32F103ZGT6 (1 MB Flash, 96 K RAM)

.

The application uses the stm32f10x_stdperiph_lib v3.5.0, FreeRTOS V6.10, FatFs R0.08b and

the SD-Card example code from stm32_eval_sdio_sd.c/h.

None of my SD-cards works with the 4b BusWide Mode. I i tried out a 4GB Transcent (SDHC Class 10) Card, a 2 GB Sandisc Card (SD Class 6) and a 512 MB Sandisc Card (Class 4), without any acceptable results... ''Sometimes'' it works, but mostly not. The higher the Clk-Div the better. If the Init with the 4b Mode works, i´ll get write/read Speed of about 2-3 MB/s, but although many errors while writing.

If i use the 1b Mode, the Application works perfectly, but then the write and read-speed is very slow (SD_WriteMultiBlocks)...

Posted on July 18, 2012 at 14:00

How is the interface wired? Are you using pull-up resistors?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tobias239955
Associate II
Posted on August 23, 2012 at 08:49

Hey clive1,

i´m sorry for my late reply, i was in holiday the last weeks. The interface is now wired as in the

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/CD00178166.pdf

described. I checked my design and recognized, that i was using 10kOhm Pull-Up resistors and not 47kOhm. So i changed the resistors to 47kOhm but the error is the same. I found out, that i can READ from the SD-Card in 4bit-wide-mode perfectly (with a nice transfer rate of about 2-3mb/s (depends on the ADC-frequency and processor load)), but i can WRITE only! in 1-bit-wide-mode.

My workaround is now a routine, which tries to initialize the SD-card in 4bit-mode with the highest clock frequency and slows down this frequency until only sometimes a write/read errors occur. If this doesn´t help, it also it slows down the bus-wide to 1 bit mode and put the frequency up to highest value...(and so on)... This method works just fine, i manage different clocks and bit modes separately for read and write routines and now i get no write/read errors. But i still have the problem, that the write-speed is a bit slow with 1 bit mode...

John F.
Senior
Posted on August 23, 2012 at 09:36

The schematic does not show any decoupling capacitors. Have you decoupled the power supply close to the SD card power pin? I would expect you to need at least 100n in parallel with 4u7 ceramic X7R with 100u tantalum or similar bulk decoupling nearby.

tobias239955
Associate II
Posted on September 03, 2012 at 09:35

John, thank you so much!!

I added these capacitors and now it works much better with the 4 bit mode! I now get 2,5mb/s write and read speed.

THANK YOU!