Not that I disagree with you, however, look at the RETI for th 8051. Also, check out the RET and RETI instruction explanantion is the instruction set manual. Both of the latter use the same stack operation implying they function the same. RET returns to the instruction following the CALL, RETI does not. I've changed my code to accomodate the RETI. Doesn't make much sense to have infinite loops. RETI (80C51 Instruction Set) Function: Return from interrupt Description: RETI pops the high- and low-order bytes of the PC successively from the stack and restores the interrupt logic to accept additional interrupts at the same priority level as the one just processed. The Stack Pointer is left decremented by two. No other registers are affected; the PSW is not automatically restored to its pre-interrupt status. Program execution continues at the resulting address, which is generally the instruction immediately after the point at which the interrupt request was detected. If a lower- or same-level interrupt was pending when the RETI instruction is executed, that one instruction is executed before the pending interrupt is processed. Example: The Stack Pointer originally contains the value 0BH. An interrupt was detected during the instruction ending at location 0122H. Internal RAM locations 0AH and 0BH contain the values 23H and 01H, respectively. The following instruction ----- Original Message ----- From: "Volkmar Dierkes" <avrfreaks@dierkes.info> To: <AVR-Chat@yahoogroups.com> Sent: Tuesday, August 23, 2005 12:50 AM Subject: [AVR-Chat] Re: mega 168 Dennis, I am sorry, but you are wrong. In an interrupt driven system, an interrupt may occur at any time. If the serving of the interrupt would end in returning to a different address, the code wouldn't be executed in the desired sequence. If you want to wait in a loop until the interrupt is being serviced, you need to set a flag in the ISR and check this flag in your loop to exit it at the given time. Please reread the datasheet to understand the interrupts correctly. Volkmar On Sun, 21 Aug 2005 21:45:48 -0500, Dennis wrote: > What I am saying is the next instruction is not being executed. In an > interrupt driven system, a loop is waiting for the interrupt. When it > happens the process continues from the instruction following the loop. It > doesn't go back to the loop, or not supposed to. > D > ----- Original Message ----- > From: "Larry Barello" <yahoo@barello.net> > To: <AVR-Chat@yahoogroups.com> > Sent: Sunday, August 21, 2005 9:33 PM > Subject: RE: [AVR-Chat] mega 168 > > >> If what you are saying is true (and it isn't) then this very common >> programming idiom won't work since an interrupt on the "rjmp" instruction >> will cause it to exit. >> >> Forever: >> Rcall DoThisTask >> Rcall DoThatTask >> Rcall etc >> Rjmp forever >> >> Please re-read my previous response again. What is pushed is the address >> of >> the next instruction to execute, not the next address. >> >> Cheers! >> Yahoo! Groups Links
Message
Re: [AVR-Chat] Re: mega 168
2005-08-23 by Dennis
Attachments
- No local attachments were found for this message.