[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] How to calculate loops?

From: Laszlo
Subject: Re: [avr-gcc-list] How to calculate loops?
Date: Fri, 06 Aug 2004 00:20:28 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113

I'm going way out on a limb, since (ducking) I don't even have avr-gcc. I've done all my work in ASM so far. If (and I'm speculating here) _delay_loop_1() takes a 8 bit parameter and simply counts down clock ticks, you would be looking at a loop of about 3 clock cycles per count: one clock cycle for the DEC and [about] two cycles for the BRNE. So multiply that .25us period per cycle times 3 cycles per loop times the parameter passed in. Also, the very last BRNE check only takes one cycle, not two; So subtract one cycle at .25us from all of that.

_delay_loop_1(1)  = (.25us * 3 * 1)  - .25us = 0.5us
_delay_loop_1(69) = (.25us * 3 * 69) - .25us = 51.5us

If _delay_loop_1() is actually a subroutine (rather than a macro), add to that about another 7 cycles for the RCALL/RET.

If someone realizes I have no idea what I'm talking about, I'll gladly accept a good smacking-down. ;)


Johan Nilsson wrote:
im using the avr-gcc _delay_loop_1(), but where do i find how long time it goes? if i use 4Mhz , and the AVR instuctions takes one cycle, how long execution time does that instruction take?
Does it take 0,25 mikroseconds?
Can anyone explain this to me?

"That's the last time *I* answer to the name 'Sarah Conner'!" - me

reply via email to

[Prev in Thread] Current Thread [Next in Thread]