Forum Discussion
Altera_Forum
Honored Contributor
10 years agoWell, I found this document which states the following:
ftp://ftp.altera.com/up/pub/tutorials/de2/computer_organization/tut_nios2_introduction.pdf Section 9.2 upon completion of the interrupt-service routine, the execution control is returned to the interrupted program by means of the eret instruction, as explained above. however, since an external interrupt request is handled without first completing the instruction that is being executed when the interrupt occurs, the interrupted instruction must be re-executed upon return from the interrupt-serviceroutine. to achieve this, the interrupt-service routine has to adjust the contents of the
ea register which are at this time pointing to the next instruction of the interrupted
program. hence, the value in the ea
register has to be decremented by 4 prior to executing the eret instruction. Sounds like your handler must decrement 4 from the ea in order to jump back to the correct pre-irq location. I find it rather odd that this must be done. I figured this would automatically be done "behind the scenes". Oh well, glad I figured it out. Hope this helps others as well.