avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] undefined reference to delay_ms


From: Matthew MacClary
Subject: Re: [avr-chat] undefined reference to delay_ms
Date: Mon, 22 Aug 2005 12:44:39 -0700
User-agent: Mutt/1.4.1i

On Mon, Aug 22, 2005 at 01:44:46PM +1000, Curtis Maloney wrote:
> in the AVR headers it's _delay_ms() ... note the leading underscore.

> Also beware of the maximum timeout - 262.14ms / Freq(in MHz)

    Here is an include file I use any time I want to use delays in a
project, it gets around the short timeout periods and doesn't need an
underscore.  Two notes: I used _delay_loop_2() for some reason, but I
don't have to since F_CPU is defined... Also I think that 64 bit
integers aren't actually used even when the code snippet requests
them, but maybe that was an old problem that is fixed now??


#ifndef DELAY_UTIL
#define DELAY_UTIL

#undef F_CPU
#define F_CPU 16000000UL /* 16MHz */

#include <avr/delay.h>

void delay_ms(uint64_t time) {
  uint64_t i;
  for (i = 0; i < time; i++) {
    _delay_loop_2(4000);
  }
}

#endif


-Matt




reply via email to

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