cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RB SDIO

matas
Associate II
Posted on August 05, 2015 at 20:37

Hi all, there is something wrong with my project's microSD card part. I have done it on the  STM32F407 discovery board and it worked perfectly the data was succesfuly written to the microSD card. But for the end product I made board (whom all traces are correct, checked it many times) with STM32F401RBT6 and now the microSD card always not responds, I get error:''SD_CMD_RSP_TIMEOUT'' and later turn into FR_INVALID_OBJECT. I have changed the from startup_STM32F4xx.s to startup_STM32F40xx.s. And I am using STM324xg_eval.c and stm324xg_eval_sdio_sd.c as drivers. Also changed the clockfrom 168MHz to 84Mhz. The divider valus are:

*pll_n 336

*pll_m 8 (onboard external 8Mhz quartz)

*pll_q 7

*pll_p 4

APB1 Prescaler 2

APB2 Prescaler 1

 If you have any suggestions, ideas or questions you are very welcome to post. 

#stm32f401
13 REPLIES 13
Posted on August 05, 2015 at 20:58

I've built and posted examples for the 401C-DISCO

Try the .HEX file I posted for Ahmed about 50% down

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/sdio%20fatfs%20speed%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=1730

it outputs via the SWV Viewer @ 42 MHz.

Further down is a 401C project, but it lacks some of my integrity checking code.

I believe this has also been discussed in the Nucleo context (SDIO card wired up to a 401RE or some such), but the thread is not jumping out from a quick search.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matas
Associate II
Posted on August 06, 2015 at 09:00

Hi again, thanks for replying, I've tried your first suggestion and here is the result (attachment), the flash was succseful, but when I tried to use SWV at 42MHz, nothing happened. Do you have to change any other settings, to launch SWV? 🙂 Now I am going to try your other suggestions 🙂

________________

Attachments :

1.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0lx&d=%2Fa%2F0X0000000bdT%2F7pfuYbxPiXmBNIDhXdnrtkHaoASQvNzxJm2q_oZHwYw&asPdf=false

2.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0k2&d=%2Fa%2F0X0000000bdU%2FGn1iWE2EXRbVT8XtBbMrPUM5_EQvv_Vmikg840ue75A&asPdf=false
matas
Associate II
Posted on August 07, 2015 at 14:27

Hey I've tried to load your project the name is ''STM32F401 Discovery SDCard + FatFs Test - CLIVE'', yet still I end up with the same error SD_CMD_RSP_TIMEOUT. The only thing I could not use in your project was the startup file because I am using IAR embedded workbench and it seems it is not compatable (bunch of errors). 🙂 Do you think the problem could be because of the startup file (startup_stm32f4xx.s) and not the startup_stm32f401x.s? 🙂

matas
Associate II
Posted on August 07, 2015 at 15:27

Found a good startup file (startup_stm32f401xx.s) - 0 errors, 0 warnings, but the problem remains.. 🙂

Posted on August 07, 2015 at 15:50

The SWV requires the SWO (PB3) pin be wired to the JTAG/SWD interface.

Wiring and power issues tend to be the primary cause of failure. Perhaps an issue with the socket. I used a relatively low cost eBay MicroSD socket, and STM32F4-DIS-BB. And have built STM32F2/4 boards using MicroSD sockets. Trace lengths of the order of 2'' pull-up resistors close to the socket.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matas
Associate II
Posted on August 10, 2015 at 16:47

Hey, the programming works, because the STM32F401 also connects to a sensor through I2C and it successfully does it, so I think the SWD works correctly. Checked the power several times and it stays in place- 3V. I've debbuged the problem more carefully and got this info:

error ''SD_CMD_RSP_TIMEOUT''

it gets the error when enters the function called ''static SD_Error CmdError(void)'' and checks for error conditions for CMD0. I'll try to dig around and find out what is CMD0. 🙂 By the way thanks for all the help 🙂

matas
Associate II
Posted on August 11, 2015 at 16:22

So far what I've found out was this - the CMD0 is the first SPI command sent to the card which tells it to reset (

Software reset.

). In another thread I found that a user named  solved it, here is his answer ''

but I added in a few millisecond delays around the SD Init phase, and that seemed to fix the problem.''

Now I tried to place the delay (as I understood in the DSTATUS disk_initialize() function) around the if(SD_Init() != SD_OK){...}statment, but still unsuccessfully, the error remains. 🙂 I will continue to look for a solution. 🙂

Posted on August 11, 2015 at 17:40

You're using pull-up resistors in your design right? It's not clear from the post what you've actually built, and some things you can't fix in software, however hard you try.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matas
Associate II
Posted on August 11, 2015 at 17:49

Yes I did 🙂 The traces are no longer than 2cm, also checked each of the SMD resistors (47 kOhm) they seem to be in place, other than that I did not add anything else, so I think it is a software problem 🙂 The resistor are placed on each DAT(0, 1, 2, 3) and CMD and the other end goes to 3V supply 🙂