rjmp instead of reti

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder what could happen to my program, if instead of a reti at the end of an interrupt routine, i put a jump command to my reset vector. What happens to the stack and to program counter? I have tried it, but some times my program crashes.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The instructions are totally different and you have to use the correct one for the job.

reti does flag and stack manipulations

jmps of all types just adjust the program counter

if you continue to get interrupts and you never return from your isr, you will overflow the stack due to the recursion happening.

I can't think of any reason you would want to, but you can simulate a reti by popping the stack, adjusting flags, and doing the jmp yourself, but why would you want to when reti is already the correct tool for the job.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Errmm...maybe I’m being dumb here but perhaps he’d “want to” because he’d want to handle an error recovery with minimal effort/code.

If the show is unstable only AFTER a software reset then the problem is down to a difference between a software and a hardware reset. Solution: peruse the data book to see exactly what those differences are, and eliminate the ones that matter. Obviously it’s not the PC, and it can’t be the SP IF you initialize it properly in the first instance!

Terry

admin's test signature