cancel
Showing results for 
Search instead for 
Did you mean: 

sd card sometimes corrupted when access it with sdmmc in STM32L452re

Fsond.1
Associate II

Hello everyone, I'm trying to build a sensor device that uses stm32l452re as MCU, I need to save my data to sd card using sdmmc features to access it. 

i using 4bit mode and clock divide 128, but unfortunately, my sd card sometimes corrupted and i need to format it using my pc when that happens, is there wrong with my setting or its naturally happen when we use sdmmc? this is my first project using it, so i still lack of experience, thanks.

2 REPLIES 2
Danish1
Lead II

I can't rule out the possibility that clock divide 128 is wrong - it depends what your input clock is to know if the output clock (input / 128) is too high. But I'd expect for stm32L divide by 128 should keep the clock sufficiently low because they are relatively slow devices (compared with stm32H).

Do you have evidence to show if the problem is in hardware or software?

Hardware is possible if you designed your own pcb and ended up with long traces from the stm32 to the SD-card. Or if your power-supply can't deliver enough current, or it isn't adequately decoupled.

Which SD-card software are you using? Is the card formatted as FAT-32 or something else?

If you are developing code, and you get a crash in other parts of your code that happens to occur during an SD-card write, that can lead to corruption.

As can your other code overwriting critical parts of the memory used by the SD-card software.

Hope this helps,

Danish

Most all Micro SD cards are rated for 50 MHz operation.

Pull-ups on data/cmd signals?

Reduce slew-rate on short lines.

Short, uniform line lengths?

DIV 128 seems awfully slow.

How well validated is the DISKIO (FATFS) layer?

Writing the wrong data in the wrong place will trash card content pretty quickly.

Be carefully about abrupt removal of card or power before the files have been closed and the media dismounted properly.

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