This code example demonstrates how to identify the source of a trap. There are a couple of approaches to achieve this:
- Using the PCTRAP register, which provides the address that caused the trap.
- Analyzing the stack.
If the PCTRAP register is available on the device, it is recommended to use it to find the address of the source code that caused the trap.
- dsPIC33AK128MC106 microcontroller (https://www.microchip.com/dsPIC33AK128MC106)
- MPLAB® X IDE v6.20 or newer (https://www.microchip.com/mplabx)
- MPLAB® XC-DSC 3.20 or newer (https://www.microchip.com/xcdsc)
- Any of the serial terminal application. Example: Tera Term (https://ttssh2.osdn.jp/index.html.en)
- dsPIC33AK Curiosity Development Board (https://www.microchip.com/ev74h48a)
- Micro USB Cable
Open any serial terminal application and set the configuration as shown in the figure