Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: mega 168

2005-08-23 by John Samperi

At 12:12 AM 24/08/2005, you wrote:
>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.

Well there is an easy way to find out, translate your code to 8051
code and run it in a simulator and see if it works differently to
the AVR and let us know. I have been working with microprocessors for
some 25 years and with at least a dozen different families/architectures
and I haven't seen a processor behave like you expect.

You can use your loop as long as you understand that

loop:
         rjmp loop

will ALWAYS and regardless of what happens anywhere else jumps
to itself so that the next instruction to be executed is rjmp loop

If on the other hand you put some code in your loop that tests
something for true or false and that something can be changed
by an interrupt then it will work well.
Let's say you enter your loop with r16=0 and your interrupt
routine changes it to 1 then you could do the following:

loop:
         tst r16         ;Check if r16 is still 0
         brne exit_loop  ;If no longer 0 then exit the loop
         rjmp loop       ;otherwise keep on waiting
exit_loop:
         more instructions

In your code you seem to test portd for some pattern
put this test within your loop and it will work but
by having an interrupt just happening will not exit
a loop.


Regards

John Samperi

******************************************************
                         Ampertronics Pty. Ltd.
   11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
          Tel. (02) 9674-6495       Fax (02) 9674-8745
                Email: samperi@ampertronics.com.au
                  Website  http://www.ampertronics.com.au
* Electronic Design   * Custom Products   * Contract Assembly
******************************************************

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.