2019-09-25 11:47 PM
When I plug on my device and run my code on the attolic debugger for 1st time my code is working as per my given logic.However if i stop my debugger and then re-run,my program is getting stuck at hardfault.
2019-09-26 12:23 AM
Please help anyone
2019-09-26 02:12 AM
You provided very little information.
You can:
Use a debugger to find the code line you code hardfaults.
Instrument your code, to do the same without running in the debugger.
Check the values of the SCB registers, to see why it hardfaulted : www.keil.com/appnotes/files/apnt209.pdf
2019-09-26 02:50 AM
Basically I am using HAL library.So just after HAL_Init() it is going to hard fault..Since I a very new to embedded coding can you tell What exact information you want?
2019-09-26 03:09 AM
I don't use HAL.
You should be able to step into the HAL_Init() function, down to the line where it faults.
If necessary, you can even switch to disassembly mode in the debugger and single-step to the faulting instruction.
2019-09-26 04:00 AM
Okay thank you.I will try and update
2019-09-26 04:51 AM
Perhaps once you step over that critical code line, the reason becomes obvious.
With Cube involved, this is hardly ever the case.
The reverse approach, i.e. stopping your MCU in the hardfault handler, and reading + decoding the fault reason from the SCB register contents, is also highly recommended.
2019-09-26 04:54 AM
Hi,
Thanks a lot.The problem lied in the debugging process.Once I stop the debugger the code runs fine.Thankyou for your suggestion