Hardfault handler using I2C based Accelerometer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Labels:
-
I2C
-
TrueSTUDIO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 12:23 AM
Please help anyone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 2: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 2: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 3: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 4:00 AM
Okay thank you.I will try and update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 4: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-09-26 4: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
