[Top][All Lists]

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

[avr-libc-dev] [bug #34278] Seemingly overzealous "__builtin_avr_delay_c

From: Joerg Wunsch
Subject: [avr-libc-dev] [bug #34278] Seemingly overzealous "__builtin_avr_delay_cycles expects an integer constant"
Date: Wed, 14 Sep 2011 07:52:14 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv: Gecko/2010071610 Firefox/3.0.19

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

                  Status:               Need Info => Invalid                
             Assigned to:                    None => joerg_wunsch           
             Open/Closed:                    Open => Closed                 


Follow-up Comment #2:

Thanks for the archive, now I finally see the problem.  Sorry
for being blind in the first place.

The compiler is correct.  The code is:

// Delay in 1/10's of a millisecond
void msleep(INT16U ms)
    { /* This loop does not work with optimization != 0. Therefore we use
         avr-libc _delay routines K. Schwichtenberg
        INT16S i,j;
        for (i = 1; i < ms; i++)
                for (j = 1; j < ONETENTH_MS; j++); / * to give 1/10 ms*/
        _delay_ms(ms); // Changed K. Schwichtenberg

Thus, _delay_ms() is called with "ms" which is a function
parameter.  This is not supported (and has never been, but
with the current implementation, you finally get an error
while the code simply didn't do what it was expected to
do before).

A correct (with respect to what the comment above the
function says) implementation would look like:

// Delay in 1/10's of a millisecond
void msleep(INT16U ms)
  while (ms-- != 0)

In addition (and unlike the original comment), optimization
_must_ be turned on for any of the _delay_us/ms functions
to work correctly.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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