Closed GoogleCodeExporter closed 8 years ago
An alternative would be to use Hans-Juergen Heinrichs
delay_x routines with named macro wrappers for backward compability:
http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id
=665&item_type=project
These are very accurate even to sub microsecond range.
Original comment by bperry...@gmail.com
on 21 May 2010 at 8:42
One possible concern with BenF's function is the fact that micros() disables
interrupts. They'd only be disabled
for a few instructions at a time, though. Do you think this is something that
could cause problems?
Also, the routines from Hans-Juergen Heinrichs look like they only work with
compile time constants. Can't we
just use the built-in avr-libc functions in that case (along the lines of issue
256)?
Original comment by dmel...@gmail.com
on 25 May 2010 at 8:07
Also, some notes from Zack777: "I have done some testing of BenF's code
solution and I think it is the best. The
use of uint16 types saves memory. Overall the code is 20 bytes smaller than
the existing delay() function. In
addition, the accuracy is impressive. It displays an absolute accuracy of 6
microseconds on average. The
fractional error at the smallest reasonable delay, 1 millisecond, is just 0.6%.
I also confirmed that it handles
rollovers in the micros() counter correctly. There are no glitches in delay()
every 70 minutes. Adopting this code
also means not having to update the delay() documentation."
Original comment by dmel...@gmail.com
on 25 May 2010 at 8:08
I committed this. Thanks for the good code, testing, and putting in the issues
list. Please test, especially if you
think disabling interrupt is a concern.
Original comment by dmel...@gmail.com
on 25 May 2010 at 8:17
Original issue reported on code.google.com by
wes...@gmail.com
on 29 Apr 2010 at 7:41Attachments: