cancel
Showing results for 
Search instead for 
Did you mean: 

Why is MCU freezing?

kb24
Senior

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.

18 REPLIES 18

Hello Imen, actually I couldnt find problem or solution yet. I tried what @Community member​ said with 3 Hz and nothing happened to MCU, it was working. Then I tried it with motors and switched it 1/3 Hz, MCU didnt freeze but some part of circuitry were burned. So I couldnt try anything after that, it looks like there is a problem with system feed but I am not sure what does exactly causes freezing. My colleagues are designing new hardware for that part that burnt.

What we are doing is this there is a working system with PIC and we are trying to port it to STM with new hardware design. While my colleagues are designing new hardware, I am trying to remove PIC from working system and place STM on there so I can trust hardware while working on software. Things are going slowly, sorry about that. If I will see that problem I will ask here again, and if I dont see that problem with new hardware design I will tell changed parts here.

Thank you all.

Sorry to hear about REV 1.0 crashing and burning.

Can you supply schematics and layout for study?

Unfortunately I cant do it because its not my own project. I am sorry.

Then read:

AN1709

Application note

EMC design guide for STM8, STM32 and Legacy MCUs

MM..1
Chief II

And for critical safety motor design you need watchdog implemented and stop motors after error simply

Laurent Ca...
Lead II

Dear @kb24​ 

What is the status about your problem?

Did the @Dvorak.Peter​ and @MM..1​ answers help you to solve it?

Best regards

Laurent Ca...

Actually I am not the person who is working on hardware, I am doing software part and as I said before I am using old circuitry with STM instead of PIC. I uploaded same code to that board and everything is working fine so problem was our new designed circuitry. I told friends' answers to person who is working on hardware, he will consider those answers but for now he is working on different project and we don't know when he can start this project again.

Laurent Ca...
Lead II

Dear @kb24​ 

Therefore I consider this thread closed for the moment.

Feel free to reopen it when you will be back on it by posting a new answer.

Best regards

Laurent Ca...

@TDK​ @Community member​ @MM..1​ @Dvorak.Peter​ @Laurent Ca...​ 

Thank you for all your answers. After long time I turned back to this project again. I had same problem with totally new design and pcb. Then I started to use CubeIde instead of Keil. I saw its going to HardFault_Handler every time, Keil cant catch it most of the time. In debug console I saw this:0693W000008xOVJQA2.jpgthen we searched for SIGTRAP. In https://github.com/stm32duino/Arduino_Core_STM32/issues/1206 this link I saw "For the clock issue, it seems your board have an issue with the HSE Bypass (clock provided by the STLink).". My problem was valid all the time not only during debugging process. Also I saw something about HSI in errata. So we decided to change clock configurations. I was using 64 MHz with PLL, I changed it like 16 MHz with HSI. Now I have no problem. Everything is working fine. What I dont understand is this if I use 64 MHz and PLL and run MOTORS its going to hard fault but if I run LEDS or just switch relays without any load its working fine. So drawing high current damages PLL and it makes this error?