2015-08-05 11:37 AM
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 4APB1 Prescaler 2APB2 Prescaler 1 If you have any suggestions, ideas or questions you are very welcome to post. #stm32f4012015-08-05 11:58 AM
I've built and posted examples for the 401C-DISCO
Try the .HEX file I posted for Ahmed about 50% down 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.2015-08-06 12:00 AM
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=false2.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0k2&d=%2Fa%2F0X0000000bdU%2FGn1iWE2EXRbVT8XtBbMrPUM5_EQvv_Vmikg840ue75A&asPdf=false2015-08-07 05:27 AM
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? :)
2015-08-07 06:27 AM
Found a good startup file (startup_stm32f401xx.s) - 0 errors, 0 warnings, but the problem remains.. :)
2015-08-07 06:50 AM
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.2015-08-10 07:47 AM
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 :)2015-08-11 07:22 AM
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. :)
2015-08-11 08:40 AM
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.
2015-08-11 08:49 AM
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 :)