Hello XBot,
Wouldn't it be much easier to just dump all relevant registers into the NVM and do the error analysis later. A XGATE software error is something serious which should never occur. So, you might as well just resevere the extra bytes for your error log entries.
But anyway, if you want to analyze the problem right in the ISR, this is what you can do:
1. Check whether the error occured during a vector fetch or or while executing application code:
XGPC != XVBR+XGCHID*4 => Problem occured during code execution (proceed with step 3.)
XGPC == XVBR+XGCHID*4 => Problem occured during most likely during a vector fetch (proceed with step 2.)
2. Two things could have happened: The application code jumped into the vector table or a vector fetch failed. Instead of going through the hassle of analyzing both possibilities, I would just put a no-exec block on the vector table. Then you can be sure thet the problem occured during a vector fetch. Now you could try to find out which of the three vector fetch cycles went wrong:
1st V-cycle: XGPC points to read-protected or unimplemented address space.
2nd V-cycle: XGPC+2 points to read-protected or unimplemented address space.
1st P-cycle: [XGPC] is odd or points to execute-protected or unimplemented address space.
3. Next check if XGPC points to execute-protected or unimplemented address space. If this is the case, then you know that the fetching of the opcode at [XGPC] failed. Otherwise continue with step 4.
4. If the opcode at [XGPC] is a JAL- or branch instruction, then the destination address must be either odd or point to execute-protected or unimplemented address space. Otherwise continue with step 5.
5. If the opcode at [XGPC] is a LDx- or STx instruction, then you the data access must have caused the prolem. It could have been a word access to an odd address, a MPU access violation, or the address could have been in unimplemented space.
Regards,
HSW