Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    hollandb reacted to roadrunner84 in Using Subroutines as Regular Functions and Interrupt Service Routines   
    You're right, a ISR will call upon the RETI (return from interrupt) instruction, while a normal subroutine/function will cal upon the RET (return) pseudo-instruction.
    The difference is in there that a RET is a pseudo-instruction. This means that it is actually another instruction in disguise. What is actually executed is MOV @SP+,PC. Better translated as "copy the value currently at the location pointed to by the stack ponter into the program counter and then increment the stack pointer by 1 word". Since this is done after all other data has been popped from the stack, this means that the PC is loaded with the PC that was pushed onto the stack by the CALL instruction.
    On the other hand RETI is a real instruction, it does something in one go that could not be done any other way. It is essnetially MOV @SP+,SR. MOV @SP+,PC in one go. Better read as "move the top value of the stack to the status register and before its effects start, do a RET". Because the status register contains the LPM bits, they are restored (return to LPM after the ISR), but before you actually go to sleep, you restore the program counter, which does effectively let you leave the ISR and clear the stack.
    Second question: no. An attachInterrupt() will just call the given function, the real ISR (which is part of Energia) might act upon the return value from your function, but this would be part of Energia, not of the MSP430.
  • Create New...