Tracking down bus fault interrupt exception

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User8570
Level 3
Level 3
I am having issues debugging my code. Sometimes the debugger goes to an unknown location or sometimes to a bus fault interrupt exception.

Wondering any suggestions to track down which part of the code generates this or how to do a further troubleshooting.
0 Likes
4 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
jptalledo wrote:
I am having issues debugging my code. Sometimes the debugger goes to an unknown location or sometimes to a bus fault interrupt exception.

Wondering any suggestions to track down which part of the code generates this or how to do a further troubleshooting.


Which MCU are you using?
0 Likes
User8570
Level 3
Level 3
I am using the XMC4500-F100x1024-AC MCU
0 Likes
Not applicable
Bus fault may occur if you try to read data or excecute instruction from an invalid memory address. The most likely cause is incorrect pointer uasage/assignment. Bus fault may also occur if you read or excecute code from a flash memory cell with an incorrect checksum. Checksum error may occur if data is written more than once without an erase in between, even if the cell was written with the erase value or the same value tvice.
0 Likes
Not applicable
Hi jptalledo,

You could put breakpoint in your project and see if it hits the breakpoint or jump to the bus fault.
From there, you narrow down the bus fault by adjusting the breakpoint in your project.

For example, your code run from line 1 to line 100, and you put the break point after a suspicious function, let's says line 50.
If the breakpoint hits, means the function is alright and you move the breakpoint to the next function.
if the breakpoint doesn't hit and jump to bus fault, then you know the fault occurs before line 50.
Then you just keep adjusting the breakpoint before line 50 until you can hit the breakpoint.
0 Likes