Skip to main content
Visitor II
September 6, 2023
Question

STM32F446VET

  • September 6, 2023
  • 2 replies
  • 1578 views

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. 

    This topic has been closed for replies.

    2 replies

    Graduate II
    September 6, 2023

    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.

    Technical Moderator
    September 11, 2023

    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