Why is MCU freezing?
I am using STM32G030K8 and driving 3 DC motors with relays in the circuit. Also I am controlling voltage of motors with MOSFET. Most of the time its working well but sometimes when I change the direction of motor with relays MCU stops working. I am using buttons for controlling motors. If relay pins were set when it happens, pins stay set and motors still working, it is becoming dangerous. Timer or GPIO interrupts stop working. 10% of times it goes hardfault_handler, %90 of times it stops working without going hardfault_handler. What causes this? and how can I solve this problem?
Thank you.

