2025-11-25 9:36 AM - last edited on 2025-11-25 9:41 AM by Andrew Neil
Hello,
I am currently working with STM32G431RB, and I have an SD card connector on my board. When the CPU clock is below 80MHz, everything works fine. However, when I increase the clock frequency and insert the SD card into the slot, the program crashes and gives different hard fault errors (stack overflow, bus hard fault, etc.).
This is the SD card slot schematic.
Solved! Go to Solution.
2025-11-26 9:55 AM
The problem was that when I inserted the SD card, it drew a huge current, which caused the microcontroller to act randomly. I changed the SD card capacitor to 1µF, and the problem was solved.
2025-11-25 9:42 AM
2025-11-25 10:05 AM
This is one example of the error. I'm using IAR Workbench, and no peripheral is activated, and the only code that I'm running is
while (1) {
if (! SD_DET)
HAL_GPIO_WritePin(led_GPIO_Port, led_Pin, GPIO_PIN_RESET);
else
HAL_GPIO_WritePin(led_GPIO_Port, led_Pin, GPIO_PIN_SET);
}
2025-11-25 12:16 PM
Almost certainly not that code. Looks at a disassembly for the addresses reported in the registers.
Check Flashwait states.
Check voltage and capacitors on VCAP pins.
Check interrupt handlers and callbacks.
2025-11-26 9:55 AM
The problem was that when I inserted the SD card, it drew a huge current, which caused the microcontroller to act randomly. I changed the SD card capacitor to 1µF, and the problem was solved.