ARM Technical Support Knowledge Articles

IDENTIFY INSTRUCTION CAUSING CLASS B HARDWARE TRAP

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

My 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?

ANSWER

You 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 ("
Class B Trap at PC=0x%02X%04X TFR=0x%04X
", 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 INFORMATION

SEE ALSO

Article last edited on: 2005-07-22 16:38:32

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential