We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm getting Class B Illegal word operand access trap on a C161 board and I don't know why. The problem is reproducable, but moves unpredicatably as I modify the code. My trap handler spits out the top three stack entries, but they don't look credible, and the system continues running after the trap without visible problems. Short of hiring an ICE, does anyone have any advice?
add the TRAPS.C module (from folder Keil\C166\LIB). The current version contains a printf statement that you may use to analyze the instruction address.
I've done that anyway. The CSP:IP doesn't make any sense and doesn't tell me where to look.
Did you examine the registers?
When a hardware trap occurs the PSW, CSP (in segmentation mode), and IP are pushed on the internal system stack and the CPU level in register PSW is set to the highest possible priority level (i.e. level 15), disabling all interrupts.
The bit-addressable Trap Flag Register (TFR) allows a trap service routine to identify the kind of trap which caused the exception. Each trap function is indicated by a separate request flag. When a hardware trap occurs, the corresponding request flag in register TFR is set to 1.
So look at the stack to determine where you came from in your code and the value of the TFR register. Then go to that place in the code to find out why you are in a class B trap.
I've sorted it now. Looking at the registers was the crux of the problem, as it's not easy to unwind the stack to find the instruction which generated the trap. Once my trap handler did this correctly, I could make some progress.