cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 & SDIO - card won't respond

peterm
Associate II
Posted on February 09, 2017 at 02:08

I've got a custom board with a STM32F103 that connects to a micro SD card using 1 bit SDIO. I've generated some basic test code using STM32CubeMx Rev 4.19.0 and STM32CubeF1 release 1.4.0 (both the latest according to the software & ST website). All it does it try to write a test file to the SD card.

I've got a scope on the SDIO_CMD, SDIO_CK and SDIO_D0 lines to see what is happening - and the answer is 'not enough'!

I can see the CMD0 command being clocked out - checksum matches the SDIO specs - at 162kHz. But the card doesn't respond. I then see the CMD8 command clocked out, again no response. And then I see CMD55 clocked out with no response. At this point stm32f1xx_hal_sd.c gives up in the SD_PowerON() function because it needed a response to that one (it doesn't seem to care too much about the rest).

I have no idea why the card doesn't respond. I've double/triple checked the pinout on the socket is correct and the card pins are connected to the correct micro pins. I've checked the card has 3V3 on it (same as micro). I've tried adding a pull-up to SDIO_D0 (suggested elsewhere to stop it going into SPI mode) but that doesn't help.

I've tried 3 cards - two are 1GB and one is 8GB. All of them work ok when I put them in a SD card reader attached to my PC.

I tried playing with the micro clock settings - I can change the clock frequency for the initialisation routine from 40kHz (out of spec) to 320kHz (in spec) and it makes no difference.

Help! What next?

#stm32f103 #stm32cubemx #sdio
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 09, 2017 at 06:00

Dear mcconaghy.peter,

Add external pullup on CMD and other floating DATA bus Line too.

SD/MMC specification doesn't allow bus floating.

As I said in other thread, don't trust internal pullup.

https://community.st.com/0D50X00009Xke3lSAB

Best Regards,

Nemui.

View solution in original post

4 REPLIES 4
peterm
Associate II
Posted on February 09, 2017 at 02:14

Card is hooked up with:

Pin 1 - DAT2 - floating

Pin 2 - DAT3 - floating

Pin 3 - CMD - SDIO_CMD to micro

Pin 4 - VDD - 3V3

Pin 5 - CLK - SDIO_CLK to micro

Pin 6 - VSS - GND

Pin 7 - DAT0 - SDIO_D0 to micro, (tried 10k pullup to 3V3 but didn't make any difference)

Pin 8 - DAT1/nIRQ - floating

Posted on February 09, 2017 at 06:00

Dear mcconaghy.peter,

Add external pullup on CMD and other floating DATA bus Line too.

SD/MMC specification doesn't allow bus floating.

As I said in other thread, don't trust internal pullup.

https://community.st.com/0D50X00009Xke3lSAB

Best Regards,

Nemui.

Posted on February 09, 2017 at 07:40

aaaaagggggghhhhhhhhhhh!! I'd tried pullups on some of the lines but not all and had read on many sites that they weren't needed. Looks like they are... I've just written my first file on this board!! Shame about the wasted 3 days... grrrr

thanks for you help.

Posted on February 09, 2017 at 23:59

I think the F1 is more problematic with internal pull ups than the F4. My own boards have pull ups externally close to the card socket, but have used other where the internals were sufficient but the traces were very short.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..