Illegal word operand access trap

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User15936
Level 1
Level 1
For our project we use the XE167FH controller. I notice that the ILLOPA trap is triggered when the MCU is rather busy.

The information from the datasheet is quite limited regarding this issue:

Illegal Word Operand Access Trap (B): Whenever a word operand read or write
access (including Flash commands!) is attempted to an odd byte address, the
ILLOPA flag in register TFR is set and the CPU enters the illegal word operand
access trap routine.

What may trigger this trap and shouldn't the compiler generate clean code in order this not to happen? And how do I exit the trap function in a decent way, so that my program can continue? Because right now, it just seems to get stuck, even if I have my own defined trap routine.

Thanks in advance,
Daan
0 Likes
1 Reply
User15936
Level 1
Level 1
With the support of a Tasking/Altium engineer I got this very nasty bug resolved. It turns out that the compiler has the "feature" to share register banks whenever
multiple interrupt service routines are defined in the same source file. So if one ISR will be interrupted by another ISR, all registers from the bank used will be overwritten,
on return to the first ISR, the registers used will contain rubbish, causing illegal data and pointers, which results in the trap. To avoid this, all ISRs must have
their own register bank, this is achieved by using the _using(REGISTERBANK_NAME) keyword. After applying this resolution, the trap didn't occur any more.
0 Likes