[bug #17216] change to the ../util/delay.h header for increased functionality

View: New views
12 Messages — Rating Filter:   Alert me  

Parent Message unknown [bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

                Priority:              5 - Normal => 9 - Immediate          


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

              Item Group:                    None => Header files          


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

                Priority:           9 - Immediate => 7 - High              


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

             Assigned to:                    None => joerg_wunsch          

    _______________________________________________________

Follow-up Comment #1:

Sorry, processing delayed for the following reasons:

. doxygen documentation is missing
. the SBIW instruction used in _delay_loop_3() is marked as
  not being available in all devices; a proper implementation
  has to reflect this

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

                Category:                  Header => Feature Request        
                Severity:              3 - Normal => 1 - Wish              


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

                 Release:                    None => Any                    

    _______________________________________________________

Follow-up Comment #2:

The last comment by Joerg is over a year old. Either we need to fix the new
functionality, or close this bug report.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Update of bug #17216 (project avr-libc):

                  Status:                    None => Need Info              


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #3, bug #17216 (project avr-libc):

Is is possible to move this forward?

The existing delay macros/functions do have problems.

For example, when using _delay_us(), if the delays are short,  the code is
too simple and will insert too many cycles by using a loop count of 1 on a 3
cycle delay loop instead of a variable number of NOPs. This means you can
never get a delay shorter than 3 cycles.
Also, when calculating the number of loops for the 3 cycle delay function,
truncation instead of rounding up occurs, which means that the delay can be
shorter than requested. The remaining 1 or 2 cycles needed are simply lost.
This function does not properly handle the delay when the number of cycles
needed is not a multiple of 3.


_delay_ms() is also too simple. When the delay is long, it drops into a loop
calling a routine that is using a fixed number of clocks. Since the delay
inside each interation of the loop is not exact, the divergence between the
desired delay and the actual delay expands with each iteration through the
loop. Unfortunately the fixed number of clocks chosen is a short delay, which
means there will be many iterations of this loop.
The same rounding error as described above in _delay_us() also exists in this
routine other than the multiple is 4 rather than 3.


The new versions of the delay functions, treat the delay cycles in their
entirety so they don't suffer from those types of problems and are able to
achieve delays accurate to within 1 clock cycle.

   

IMHO creating the needed documentation for the new delay.h should not be a
roadblock as it is fairly simple and straightforward.

As far as the sbiw instruction goes, this is already being used by the
existing implementation.
The existing implementation calls _delay_loop2() which uses sbiw

What is needed to get the ball moving again?





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

RE: [bug #17216] change to the ../util/delay.h header for increased functionality

by Weddington, Eric :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From: Bill Perry [mailto:INVALID.NOREPLY@...]
> Sent: Monday, August 17, 2009 3:41 PM
> To: Joerg Wunsch; Bill Perry; Weddington, Eric;
> avr-libc-dev@...
> Subject: [bug #17216] change to the ../util/delay.h header
> for increased functionality
>
>
> Follow-up Comment #3, bug #17216 (project avr-libc):
>
> Is is possible to move this forward?
>
> The existing delay macros/functions do have problems.
>

Hi Bill,

There is a patch to the GCC toolchain, which has been included in the last two releases of WinAVR, that provides new builtin functions, including a function that will delay a specified number of cycles:

extern void __builtin_avr_delay_cycles(unsigned long __n);

The parameter to this function is an unsigned long which is an unsigned 32-bit number of cycles to delay. When you use this function in your application, GCC will replace the function with "do-nothing" assembly code that will delay the specified number of cycles.

This function has not been widely advertised, but it should work for you. Perhaps this will help you in your search for a better delay.

Eric Weddington


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Parent Message unknown RE: [bug #17216] change to the ../util/delay.h header for increased functionality

by Weddington, Eric :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From: Bill Perry [mailto:bperrybap@...]
> Sent: Tuesday, August 18, 2009 1:14 AM
> To: Weddington, Eric
> Subject: Re: [bug #17216] change to the ../util/delay.h
> header for increased functionality
>
> All these patches are a real challenge to keep up with.

I understand completely. I suffer the same challenge.

> How would the average AVR developer ever find that builtin function?

Well these functions are a bit new, so we haven't widely advertised their existence. And this is still in a patch form and have not yet been committed upstream.

 
> But now that it works, can we update the <util/delay.h> to use it?

Patches welcome.
 



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Re: RE: [bug #17216] change to the ../util/delay.h header for increased functionality

by Joerg Wunsch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As Weddington, Eric wrote:

> > But now that it works, can we update the <util/delay.h> to use it?
>
> Patches welcome.

The big thing I'm seeing with __delay_cycles is: How to *detect* it
from <util/delay.h>?

Either, the patch (and future public implementation) can "announce"
itself by the existence of a preprocessor macro, so applications could
e.g. write

#if defined(__HAVE_DELAY_CYCLES)
  __delay_cycles(n);
#else
  __delay_loop_1(n / 3);
#endif

(this would IMHO be the best solution), or we have to rewrite
avr-libc's source code to derive the actual <util/delay.h> from a file
named delay.h.in, where the final file is generated at build time,
based on some autoconf probed compiler feature.  Obviously, this is
more effort to implement, and it will only work provided the compiler
avr-libc has been configured for is the same avr-libc is then going to
be used with.

--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

[bug #17216] change to the ../util/delay.h header for increased functionality

by gry-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Follow-up Comment #4, bug #17216 (project avr-libc):

Further continue discussion from the avrfreaks thread:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=619023#619023

I think it is easy to set proper expectations for a new _delay_ns() function
through proper documentation so that people won't get a false impression that
the routines provide better precision than is actually possible

My overall desire is to have more accurate and more predictable delays for
the short delays and more importantly that a delay is never shorter than what
was requested.

The drop in alternate routines that Hans-Juergen do both of these in a fully
backward compatible way.

Long term it may be good to even re-write Han's routines to use the
__builtin_avr_delay_cycles() function or even provide an additional builtin
delay function that take 2 arguments:
- a CPU clock rate
- a time to delay.
That way the entire functionality is handled by the compiler.









    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?17216>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/



_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@...
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev