2026-03-17 10:39 PM - last edited on 2026-03-23 12:53 AM by mƎALLEm
So, when I was actually trying to work on the STM32F103CBT6TR MCU which is placed onto the custom board while I tried to toggle PA1 in it which only gave floating values then in debug, I found out it is going into Hard Fault Handler so then again I replaced them with new IC but again it is coming as same Hard Fault Handler. I also tried for pin 0 too. What can we do to solve this?
2026-03-18 1:51 AM
Okay, let's go with your scenario fake MCU all then can you just say what might be the error in code. I configure PA0 and PA1 as output that is GPIO_Output in cube mx that is available in cubeIDE itself and have generated code by itself not written by me, you know the pre-written code right. So, initially everything is okay then as you see in while (1) I wrote the syntax for toggle and its delay 500 ms (milli sec) okay. I would be glad, if you can pinpoint out where is the issue as you see the process that I have done and where do you think the code is the actual issue? If something is wrong of syntax, then I would not be able to build it or even flash it. But to say more clear of your statement, “The MCU (STM32F103CBT6TR) was purchased directly from ST’s product line.
2026-03-18 5:25 AM
... and have generated code by itself not written by me, you know the pre-written code right ...
That does not make it "right", obviously.
Aside from individual mistakes like choosing a wrong variant & package, Cube code is known to contain bugs. And not just a few.
> If something is wrong of syntax, then I would not be able to build it or even flash it.
Which means even less. Being able to compile some code can by no means equated to being correct.
There is something like "semantics", i.e. what the code actually tries to achieve. This needs to follow the datasheet / reference manual of your MCU, and the requirements of your application.
The syntax are the constraints of the programming language, about how to express the problem.
Long story short - run your application in the debugger, until it faults.
Read out the error registers of the SCB peripheral to decode it. See here : https://www.keil.com/appnotes/files/apnt209.pdf
Crosscheck with your code or the map file what the error location and cause refer to.
> But to say more clear of your statement, “The MCU (STM32F103CBT6TR) was purchased directly from ST’s product line.
Fine with me. With fake MCUs, you get non-reproducable results - and the ST staff here refuses to support any issues caused by those fakes. For good reasons, I guess.
2026-03-18 9:35 PM
I actually right now don't get the hard fault handler error but rather "sigtrap" like this
what actually should be done to clear out this? Any idea on it.
2026-03-19 2:04 AM
I suspect your code fails to handle all necessary interrupts and exceptions.
2026-03-19 2:54 AM
Is this the dead end of this issue like, do we don't have any other options?
2026-03-20 12:04 AM
It seems the issue can be controller itself. Why dont you try another controller with your custom board?
2026-03-20 12:12 AM
Well, I am working on a custom board with STM32F103CBT6TR. Although some have suggested changing the MCU, this device is fixed for my design and I need to work with it. I have already replaced the IC twice (same part number), but the issue persists: initially the code entered a HardFault, and now it consistently hits a SIGTRAP even with all breakpoints removed. The GPIO pins are still not toggling. Could this indicate a possible hardware issue on the board, or should I focus more on the software/debug configuration?
2026-03-20 12:29 AM
I would suggest to look at the hardware part of the custom board now.
2026-03-20 1:52 AM
Well, I will see to it and update it over here, thank you.
2026-03-20 3:03 AM
One more thing "if possible" to replace your Blue Pill controller with custom board controller and then check if Blue pill board goes into same problem as custom board.