[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] does delay.h really need all this junk?
From: |
Steve Franks |
Subject: |
Re: [avr-libc-dev] does delay.h really need all this junk? |
Date: |
Tue, 9 Dec 2008 11:22:01 -0700 |
>> -----Original Message-----
>> From:
>> address@hidden
>> [mailto:address@hidden
>> org] On Behalf Of Steve Franks
>> Sent: Monday, December 08, 2008 5:06 PM
>> To: address@hidden
>> Subject: [avr-libc-dev] does delay.h really need all this junk?
>>
>> Y'all,
>>
>> I was trying to figure out why _delay_us() was eating up all my flash
>> in a tiny2313, so I threw in a <link> -nodefaultlibs, and look what I
>> found! Is this really just for the convinienece of using F_CPU? I
>> grabbed delay_loop_2(), put it in a for() loop, and my code went from
>> 4k to 1k...
>
> Read the documentation on _delay_us(). You need to use a constant value for
> the parameter, and you need to turn optimizations on.
>
Right. Well, never liked the lack of warning when you overflow
anyhow. I just wrapped delay_loop_2 in a while (delay > 65535) - type
loop. I can live with the minimal overhead of the while and
delay-=65536 getting calc'ed a few times. I usually want a delay
equal to or slightly longer than the requested value when waiting for
I/O's to settle and the like anyway. Suprised no one has ever made
something like this official. Interesting goodies starting to appear
in the util folder, I noitce...probably been there for years (i.e.
setbaud)
Steve