| |||||
Technical Support Support Resources
Product Information | C166: IDENTIFY INSTRUCTION CAUSING CLASS B HARDWARE TRAPInformation in this article applies to:
QUESTIONMy program generates a Class B Hardware Trap which indicates execution of:
How can I determine the reason of the Class B Hardware Trap and the CPU instruction that causes this problem? ANSWERYou can add the TRAPS.C file to your application. This file contains a TRAP Handler for 166/167/XC16x hardware traps. The current version of this file contains a PRINT_TRAP define that you can enable. This adds the following code to your program:
#include <intrins.h>
.
.
.
#pragma NOFRAME // do not save registers for following interrupt
void Class_B_trap (void) interrupt 0x0A {
unsigned int ip, csp;
ip = _pop_ ();
csp = _pop_ ();
printf ("\nClass B Trap at PC=0x%02X%04X TFR=0x%04X\n", csp, ip, TFR);
/* add your code here */
while (1); /* end-less loop */
}
The printf statement outputs (via the serial interface) the PC address and the Trap Flag Register (TFR) value. You can load your application into the µVision Debugger and enter the Unassemble command in the Debugger Command Window. This typically displays the instruction (or the instruction after the instruction) that caused the Class B trap. The TFR value indicates the Class B Trap reason. For C16x/ST10 based devices the following TFR values are defined:
For XC16x/Super10 based devices the following TFR values are defined:
MORE INFORMATIONSEE ALSOFORUM THREADSThe following Discussion Forum threads may provide information related to this topic. Last Reviewed: Friday, July 22, 2005 | ||||
| |||||