cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 SD Card works at 80MHz CPU clock; Hard Faults at anything higher

mohamadmeymandi
Visitor

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.

mohamadmeymandi_0-1764091409212.png

 

2 REPLIES 2
Andrew Neil
Super User

 

Debugging Hard Faults.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

mohamadmeymandi_0-1764093620493.png

 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);
}