Infineon TriCore: Unknown trap (exception) is causing problems during application development

11-Jul-2024

TriCore architecturally does not have a mechanism that would allow the CPU to be stopped when a trap (in some other architectures known as an exception) occurs. Various mechanisms can trigger traps on the core, such as null pointer dereference or data alignment errors.


Possible solutions

Scripts

Trap handler scripts help to stop the TriCore on entry to the trap handler and decode the trap that is being serviced: 

  • Set Trap breakpoints - winIDEA sets the breakpoints according to the current value of the BTV register. 
  • Report active Trap - A console window appears and in it, the report is printed.

The scripts can be invoked via Tools | SoC Scripts. 


winIDEA Configuration

Trap table address is written in the BTV register. Its value can be obtained with the help of the SFR Window. In this case, the start of the trap table is on the address 0xA0000000.


1. Open the SFR Window and locate the address. 

2. Configure range execution breakpoint through Debug | Hardware Breakpoints.

  • Access - Range breakpoint that will hit on Instruction execution between 0xA0000000 (BTV) and end of trap vector table.
  • Event associated - Halt
  • CDC Suspend-Out - Active
  • Break - BEFORE



After a trap occurs, the CPU will stop in the trap handler. The program counter will be located at the BTV register value, ORed with Trap Class Number (TCN), which is additionally shifted left by 5 bits. The trap Identification Number (TIN), which is also needed for precise decoding of generated trap, is located in register D15.

Assuming BTV[7:0] is zero, we can decode both TCN and TIN in the Watches Window.



In the case of TriCore TC1.6.2, this trap is Internal Protection Trap - Memory Protection Null Address. For other traps consult Infineon TriCore documentation.


More resources in winIDEA Help

Was this answer helpful?