cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446VET

MBolo.1
Associate III

Hi, I have a custom STM32F446 board. On this board I have an microSD slot that is connected through  SDIO (PC8,PC9,PC10,PC11,PC12 and PD2 pins)

In order to write on the microSD i follow this instructions https://community.st.com/t5/stm32-mcus/how-to-create-a-file-system-on-a-sd-card-using-stm32cubeide/ta-p/49830

This is the schematics of the card connection 

134453343434343.JPG

and this is the code that I run

User1.JPGuser2.JPG

at f_mkfs() function it returns FR_NOT_READY. If I continue to run the code and run f_open() it returns FR_INVALID_OBJECT.

My questions are:

1.Could the first result be cause by the fact that Card Detect and is connected to ground and if so how to fix that in the code? where that function is located?

2. Could this be due to wrong frequency on SDIO? I used 48, 25 and 16 and all with no result.

PS I had only one instance  when it created the file STM32.TXT but even then the content was corrupted, instead of "STM32FATFS WORKS GREAT" I got some random symbols, and also I was not able to recreate the conditions to have the file created again.

PS2: card used is ONN 32GB formatted in FAT32. 

2 REPLIES 2

Debugging tips.

Don't use ANY Write functionality until you've proved the Reading works.

You don't / shouldn't have to format the cards with f_mkfs() all cards in the stores come preformatted properly / ideally.

The PLL should be running, typically at 48 MHz, and you divide down from that. MicroSD cards should be good to 50 MHz, you're interface might not be. 25 MHz or 12.5 MHz should be reasonably safe.

Use DMA, disable flow-control

Most important code is in the DISKIO layer, the top-level code is going to be next to worthless from a debugging perspective. Code here should check the card presence via a GPIO, typically to a switch on the socket design, normally with a pull-up, grounded when card inserted. Not required, null-out related code.

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

Hello @MBolo.1,

 f_mkfs() returns FR_NOT_READY. One of the following possibilities is suspected: 

  • No medium in the drive.
  • Wrong lower layer implementation.
  • Wrong hardware configuration.
  • The storage device has broken.

Would you check if FF_FS_REENTRANT is enabled or not? note that the low-level disk I/O layer must be reentrant. Check UM1721 section 4.4.2

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.