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

Level 3
Level 3
First like received

How can I debug my code when I encountered Trap?

Thank you and regards

#8042000 13007
1 Reply
Level 5
Level 5
First solution authored First like received
Hi Bernie,

For Tricore / AURIX, there are 8 Trap classes, the more common trap can be Class 2 - Instruction Errors or Class 4 System Bus and Peripheral Errors.

In general, we can follow the steps below to find out the trap reason:

1. Put one or more breakpoints for the trap class in the Trap vector table (ie, Class 2 & Class 4). The BTV register specifies the Base address of the Trap Vector table
2. Reset & run your code
3. If trap occurred for class 2 or class 4, it will stop at that breakpoint
4. Check register D[15] for TIN - Trap Identification Number
5. Check register A[11] for address of instruction triggering the trap. For a synchronous trap, the return address A[11] is the instruction that caused the trap.

Please refer to the architecture user manual volume 1 -> Chapter 6 Trap System for more details. (TC Architecture User Manual V10 Vol1)

Best regards