| |||||
Technical Support On-Line Manuals C166 User's Guide | Using TRAPS.CThe C16x/ST10 microcontroller generates several hardware traps (interrupts) for hardware or software failures. The source code of TRAPS.C (found in the \KEIL\C166\LIB\ folder) is listed below:
/***********************************************************************/
/* This file is part of the C166 Compiler package */
/***********************************************************************/
/* */
/* TRAPS.C: TRAP Handler for 166/167 hardware traps */
/* */
/* To translate this file use C166 with the following invocation: */
/* */
/* C166 TRAPS.C */
/* */
/* To link the modified TRAPS.OBJ file to your application use the */
/* following L166 invocation: */
/* */
/* L166 <your object file list>, TRAPS.OBJ <controls> */
/* */
/***********************************************************************/
/*
* Non-Maskable Interrupt
*/
void NMI_trap (void) interrupt 0x02 {
/* add your code here */
while (1); /* end-less loop */
}
/*
* Stack Overflow Interrupt
*/
void STKOF_trap (void) interrupt 0x04 {
/* add your code here */
while (1); /* end-less loop */
}
/*
* Stack Underflow Interrupt
*/
void STKUF_trap (void) interrupt 0x06 {
/* add your code here */
while (1); /* end-less loop */
}
/*
* Class B Hardware Trap:
* -> Undefined Opcode
* -> Protected Instruction Fault
* -> Illegal Word Operand Access
* -> Illegal Instruction Access
* -> Illegal External Bus Access
*/
void Class_B_trap (void) interrupt 0x0A {
/* add your code here */
while (1); /* end-less loop */
}
You may add this module to your project to detect hardware and software failures of your application. If you run your program with a debugger or emulator, you may set break points on the entry addresses of the interrupt functions. The location that caused the problem can be determined by using TRACE information or the stack contents. | ||||
| |||||