2024-06-25 01:54 AM - edited 2024-06-25 04:39 AM
MCU: STM32L471VGT6
I am trying to get an SD Card to work for my system. I am using a custom board and I cant share any drawings. However, what I am using for the SD Card:
Sd card adapter: https://learn.adafruit.com/adafruit-microsd-spi-sdio
Sd card: SDHC 32 GIG micro sd card.
The wiring is okay, I checked so many times.
The sd card and adapter works for spi, tried it on arduino.
What I have tried in STM32CubeMX:
Enable SDMMC1 (Tried both SD 1 bit and wide 4 bit)
- Formatted it on windows to FAT32
- Interrrupt on
- DMA on
- Pullup on every pin except CK
- Put sdmmc clock to 48 MHz
- DMA template enabled on FATFS
I have tried different PCB, tried different sd adapter, tried different sd card
What My code is crashing on is the f_mount. It returns
Solved! Go to Solution.
2024-06-27 04:44 AM
I found it, I had to run
2024-06-25 02:12 AM
Hello @morris and welcome to the community.
Please read these recommendations on this link on how to post a thread on the community. Especially the details of your HW (MCU part number), a concise description of your problem etc ..
So please share schematics/project etc to let community members to help you efficiently.
2024-06-25 02:26 AM
As I said I cant share any schematics
2024-06-25 02:34 AM
Hi,
f_mount is the first , that has to work. If not - no useful access to card.
Connection cpu to card at max. 50mm length;
+ What you should do :
1. set port/pins to medium or med./high speed , not high; + pullups ON an all pins to sd-card.
2. set 1-bit mode (4-bit much more critical...for later playing around...)
3. no DMA template (also...later)
4. in Cube->fatfs : enable ex-fat and long filenames (working also with 64GB ex-fat cards, as you buy them, bigger i dont have, but should work also; dont format cards, usually they have "best" matching format when new..)
Then try mount (...1); (1 = now)
2024-06-25 02:39 AM - edited 2024-06-25 04:05 AM
@morris wrote:As I said I cant share any schematics
That really cripples the possibilities for remote assistance!
Can you not at least show the connections of the SD Card adaptor to the microcontroller?
And give the full microcontroller part number.
Do you have a logic analyser to see what's happening on the wires?
Can you reproduce the issue on an ST board?
EDIT:
@morris wrote:The sd card and adapter works for spi, tried it on arduino
Are you sure it works for SDIO ?
2024-06-25 02:46 AM
@morris wrote:
As I said I cant share any schematics
Sorry this feedback doesn't help ..
2024-06-25 04:34 AM - edited 2024-06-25 04:35 AM
The pins speed made it worked. You are amazing!!! Now I can use the sd card at:
- 1 bit mode
- interrupt ON
- DMA TX/DMA RX
- Medium speed with pullup
The solution breaks when I try to:
-Enable dma template
- Enable 4 bit mode
Do I want Dma template, I have read somewhere that it acheives best performace. How do make 4 bit mode work?
2024-06-25 04:38 AM
I updated the original post with the part number of the stm.
Yep the adapter works for both sdio and spi
2024-06-25 04:58 AM
Do you have a logic analyser to see what's happening on the wires?
Can you not at least show the connections of the SD Card adaptor to the microcontroller?
Can you reproduce the issue on an ST board?
2024-06-25 05:25 AM
:)
- DMA : didnt work for me, but never tried much with this, because : WHEN i read (or write) the sd-card, i always need it NOW, so nothing different, if the cpu waits for data and transfers "itself", or waits for "dma-ready", done, same time.
But it could be better and important in other area, in RTOS system etc, because no cpu load for data transfer.
- 4.bit mode: sure, is faster, but also much more sensitive to connection (reflection, ringing etc.) on the lines;
thats also why pin-speed is important: the cpu pins are so fast switching, that this produces a lot of EMI and rf-ringing.
And also on line length: i had an adapter, about 80mm from cpu - never 4bit mode working. Same with 30mm distance working on 4bit mode, full speed (50 MHz on sdmmc module).
So dont think, 4-bit is 4 times as fast, real is: if you read lets say 8kB from card, at 25Mbit this needs about 2,6ms; but at first the command is send to card, some xx us, then card access its memory area, needs about 0.5 ...3ms, sometimes 100ms (no joke!) , so reading 8KB needs about 4ms and if you can do same at 4-bit mode, it will need about 1...3ms .