STM32G431RBT3 enters HardFault during standalone power-on but works correctly with ST-LINK
- September 7, 2026
- 11 replies
- 69 views
Hello ST Community,
I am using an STM32G431RBT3 on a custom-designed PCB. The STM32 is used to control a DRV8334 3-phase motor driver for a blower motor application.
I am facing a critical issue where the controller works correctly when using ST-LINK debugging, but it does not run correctly when the PCB is powered on standalone.
Hardware
- MCU: STM32G431RBT3
- Package: LQFP64
- Motor driver: DRV8334
- PCB: Custom-designed PCB
- IDE: STM32CubeIDE
- Programmer/debugger: ST-LINK
- MCU supply: 3.3 V
Problem
When I power the PCB directly without ST-LINK, the following happens:
- The STM32 starts executing the firmware.
- A GPIO that I set HIGH in main() becomes HIGH.
- The GPIO that I toggle inside the while(1) loop does not toggle.
- I added a GPIO HIGH operation inside HardFault_Handler().
- That HardFault GPIO becomes HIGH.
Therefore, it appears that the MCU reaches main() but subsequently enters HardFault before the normal while(1) execution continues.
When ST-LINK is connected
If I connect ST-LINK and program/debug/run the same firmware through STM32CubeIDE:
- The GPIO in the while(1) toggles normally.
- The application runs normally.
- Timers work.
- Other peripherals work.
- The DRV8334 control works normally.
So the behavior is:
Standalone power ON
↓
main() starts
↓
GPIO in main = HIGH
↓
while(1) GPIO does NOT toggle
↓
HardFault_Handler()
↓
HardFault GPIO = HIGHBut:
ST-LINK connected
↓
Program / Debug / Run
↓
main()
↓
while(1) executes normally
↓
GPIO toggles
↓
Application worksMinimal firmware test
To eliminate the DRV8334 and other peripherals, I reduced the firmware to a very simple program:
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET);
while (1)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_10);
}
}There is no TIM1, TIM4, ADC, SPI, UART, DRV8334 or motor-control initialization in this test.
Even with this minimal firmware, the problem occurs during standalone power-on.
HardFault test
I have also modified the HardFault handler:
void HardFault_Handler(void)
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET);
while (1)
{
}
}During standalone power-on, this GPIO becomes HIGH, confirming that the MCU is entering HardFault_Handler().
