Ray A,
It sounds like your ISR is overwriting the values in the accumulator. I would check to see if your Program Status Word (PSW) is properly being pushed and pulled from the stack upon entry and exit from your ISR.
Here is the link to the RL78 software manual:
http://documentation.renesas.com/doc/products/mpumcu/doc/rl78/r01us0015ej0220_rl78.pdf
I hope this helps.
Mike Clements
RenesasRulz Moderator
The problem turned out to be due to the fact that the hardware multiply uses several instructions and registers to do the work. So if an ISR occures part way through the process, the ISR is NOT storing the hardware multiply status registers and restoring them at the end of the ISR.
Therefore the main loop and ISR cannot BOTH use the hardware multiply. So the best option is (3) where the ISR uses a software multiply.
GCC currently ONLY allows the hardware multiply to be turn on or off at a file level so I have 2 choices
1) put ISR into a new file and make all variables external (NOT desirable)
2) write my own software multiply and use that in ISRs that need it
I have implemented option (2)
I hope this helps other ppl
Ray
A third possibility would be to disable interrupts while doing the multiplication. To do this you could pack the call for multiplication in a macro like this:
#define MULTIPLY(IN1, IN2, OUT) \
__builtin_rl78_di (); \
OUT = IN1 * IN2; \
__builtin_rl78_ei ();