2022-03-20 05:35 AM
I have almost 2 year experience with stm32 MCU. if I had any problem I solve it with in one or two days.
But right now I'm facing a very strange problem and stuck on it from last 25 days.. I'm working on Grid connected inverter control board. In design process i have to measure ac voltage from grid. 2 month ago I made a circuit and measure grid voltage with STM32F103 MCU and everything was fine i assume my circuit is correct and i can put it on schematic . Which final board i made it has STM32G0 series MCU. When i tried to measure voltage with board MCU stop working after 1-2 sec , i think about all issues which can cause this problem for example new MCU chip, voltage checking on supply, isolation of op amps from grid high voltage ,etc. and still same problem then i come on my code and start to find cause and then I found a very strange problem.
I use a external interrupt for measure mains voltage frequency . when I enable that code processor stop working after 2 or 3 seconds but debugger reading of DMA variable memory address still continue it means half MCU stop but half is working . and when I comment that specific code lines and run debugging everything works fine.
That code lines which cause problem screenshot is attached.
2022-03-20 06:21 AM
Seems as hard fault, place into IT some led control...
And from your screen , you do jobs in IRQ, then check priorities...
2022-03-20 06:28 AM
Output some status/telemetry via GPIO, UART etc
Instrument Hard Fault
Make sure variables are volatile if changed outside normal code flow, ie interrupt/callback
2022-03-20 06:54 AM
Yes i also change priorities but still same problem …
2022-03-20 06:57 AM
Im debugging with Serial wire debug not any message shown up in uvision when cpu stops.
yes variables are volatile.
issue is that why cpu stops after 2-3 seconds of working
2022-03-20 08:20 AM
Ended up in a while(1) loop somewhere
Hard Faulted
Stuck in interrupt context because source not cleared
Latched-Up
Perhaps have heart-beat LED in main loop, another in SysTick (highest priority), see if it's alive.
2022-03-20 08:52 AM
You debug with SWD, but no message? Debuger dont show messages for you , you need pause code or place breakpoint for locate trouble point.
2022-03-20 03:54 PM
If it stops after 2-3 seconds, it should be very straightforward to debug it, let it go a few seconds, and hit pause and see where it is and why it’s not acting as expected.
Don’t think you’ve provided enough info to spot the error. Certainly assigning values to variables won’t cause an issue in itself. The problem likely lies elsewhere in the code logic.
2022-03-20 05:37 PM
"Stops working" is not a useful description. C'mon, at least pause the debugger and determine what the CPU is doing at the time.