Moataz Hussein wrote: > > > Thanks all for your advice, I was meaning start of program i.e. full reset. > > In a book I have it is mentioned > "When an interrupt occurs the value of the program counter is stored in > the stack so that the program returns to where it was when the handling > interrupt is over." > > So is it correct that going to the start (rjmp start) at the end of the > interrupt routine instead of the RETI instruction will not help? > > Moataz > > Moataz, I believe that is what I said (below). Since you are no doubt initializing the stack pointer as one of the first tasks when you start your program, resetting it again by going to the start of your program will take care of the return value that was on it (essentially discarding it). Also, since you won't be using the RETI instruction, interrupts will be inhibited until you allow them again in your further code. There's nothing really magic about interrupts ... they are quite similar to subroutines in most ways, and the RETI is same as a return from subroutine except it takes care of the interrupt flag. What you are seeking is considered a non-standard return (just one of the tricks that we sometimes play and need to document thoroughly in your source code). Don > > All you need to do is to jump to the beginning of your program at the > end of the interrupt service routine instead of using the usual RETI > (return from interrupt) instruction. Of course, this depends on how you > initialize things too -- if you start out your program from reset and do > not assume anything is initialized and do the full initialization of > everything, then you should be OK. Just beware of the state of the > interrupt enable. All this is predicated on using assembly language and > not C. > > Don
Message
Re: Re: Re: [AVR-Chat] Interrupt routine
2006-01-02 by Don AE5K
Attachments
- No local attachments were found for this message.