2025-05-18 7:53 PM
The reason is that the update of the HAL library caused the SD card problem, which led to bus_hault after the restart. The SD card will only be restarted when there is a read/write issue. The reset process is deinit followed by init.
Later, it was found that DPSM was an unexplainable setting, causing the driver to believe that there was data directly read from the fifo, but the data program was written to DPSM in conjunction with SDMMC_CK.
Then I changed the driver code to seem to have solved the problem, and restarted the code by adding abort before deinit and init.
1、Why does the SD card often malfunction? Is it caused by the clock waveform? Is this waveform setting incorrect for DPSM?
I adjusted the frequency to 4M, but the Voltage overshoot was very large.Yellow represents CK and pink represents 3.3V voltage
2、I used a soft restart for the SD card, but it seems to be of no use. Is there a way to solve the problem of the SDMMC getting stuck at a certain state due to being stuck at the DPSM?
If the abort continues, it will cause the IDMA to step on other stack Spaces, thereby resulting in a hardfault.So if abort fails once, I won't use the SD card anymore.
When there is a problem with the SD card, it will keep waiting for the flag bit. The same is true of reinitialization
Thank you for your help.
2025-05-18 10:29 PM
>1、Why does the SD card often malfunction?
Probably a hardware problem.
- How long are wires/connection from cpu pin to sd-card ?
- pin speed you set ?
- clock for sdmmc is ..? MHz
- DMA used ? (Tried without DMA ?)
2025-05-18 11:31 PM
The cable from the CPU to the sd card is 32.9MM long
SDMMC_CK is 4Mhz
IO speed is GPIO_SPEED_FREQ_MEDIUM
yes,i use dma;I didn't try not to use dma
2025-05-19 12:18 AM - edited 2025-05-19 12:21 AM
33mm should be fine. (Is really from cpu-pin to card-pin ? or from board to card ?)
So try first:
- all pins speed medium + pullups ON
- sdmmc clock 50MHz (i use 100M and div 1 -> 50M )
- 1 bit mode
- no DMA
-> init , wait 50ms (hal-delay) , many cards need some time for internal init,
and then only mount (parameter 1 , = now ) and read (from any existing file on card), use "good" card (e.g. SanDisk).
THIS has to work perfekt .
Then we go on... ok ?
2025-05-19 12:42 AM
Sorry, there might be some problems with what I described. I'm using the 4-bit and DMA. Under normal circumstances, it can be used, but there are some occasional situations, with a probability of about one percent.
I have tried short-circuited CK to trigger its exception. It can be restored through reset, but it is not 100% restored. Sometimes it still gets stuck in cmd_act.It seems that the SD card is stuck in a certain state (because I reinitialized the SDMMC peripheral).
I think there should be better solutions. For example, when problems occur, change to 1bit to reduce the rate and do flow control. My requirement is not to reset the MCU.
2025-05-19 3:01 AM
Ok, maybe i understand your problem now.
I found also, to come occasional to a no-more-responsive-state of the sd-card :
my only working solution is : i made a p-mosfet for switching on/off the sd-card supply;
so if it "hangs up" , power off sd, reinitialize the SDMMC peripheral and power on sd -> working again.
sd-power-on is just a gpio out pin from cpu, to mosfet gate.
2025-05-19 3:35 AM
OK,thank you.I actually thought of this approach too, but at this stage, it's best to optimize the software.