AVR ATmega128 程序问题
#ifndef _UTIL_DELAY_H_
#define _UTIL_DELAY_H_ 1
#include <inttypes.h>
#if !defined(__DOXYGEN__)
static inline void _delay_loop_1(uint8_t __count) __attribute__((always_inline));
static inline void _delay_loop_2(uint16_t __count) __attribute__((always_inline));
static inline void _delay_us(double __us) __attribute__((always_inline));
static inline void _delay_ms(double __ms) __attribute__((always_inline));
#endif
void
_delay_loop_1(uint8_t __count)
{
__asm__ volatile (
"1: dec %0" "\n\t"
"brne 1b"
: "=r" (__count)
: "0" (__count)
);
}
void
_delay_loop_2(uint16_t __count)
{
__asm__ volatile (
"1: sbiw %0,1" "\n\t"
"brne 1b"
: "=w" (__count)
: "0" (__count)
);
}
#ifndef F_CPU
# warning "F_CPU not defined for <util/delay.h>"
# define F_CPU 1000000UL
#endif
void
_delay_us(double __us)
{
uint8_t __ticks;
double __tmp = ((F_CPU) / 3e6) * __us;
if (__tmp < 1.0)
__ticks = 1;
else if (__tmp > 255)
__ticks = 0;
else
__ticks = (uint8_t)__tmp;
_delay_loop_1(__ticks);
}
void
_delay_ms(double __ms)
{
uint16_t __ticks;
double __tmp = ((F_CPU) / 4e3) * __ms;
if (__tmp < 1.0)
__ticks = 1;
else if (__tmp > 65535)
__ticks = 0;
else
__ticks = (uint16_t)__tmp;
_delay_loop_2(__ticks);
}
#endif
然后在操作时出现:
Build started 10.11.2009 at 22:14:17
avr-gcc.exe -mmcu=atmega128 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT 2.o -MF dep/2.o.d -c ../2.c
In file included from ../2.c:2:
C:/WinAVR/avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
In file included from C:/WinAVR/avr/include/avr/delay.h:37,
from ../2.c:2:
C:/WinAVR/avr/include/util/delay.h:136:3: warning: #warning "F_CPU not defined for <util/delay.h>"
avr-gcc.exe -mmcu=atmega128 -Wl,-Map=2.map 2.o -o 2.elf
avr-objcopy -O ihex -R .eeprom 2.elf 2.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex 2.elf 2.eep || exit 0
avr-objdump -h -S 2.elf > 2.lss
AVR Memory Usage
----------------
Device: atmega128
Program: 258 bytes (0.2% Full)
(.text + .data + .bootloader)
Data: 0 bytes (0.0% Full)
(.data + .bss + .noinit)
Build succeeded with 2 Warnings...
出现两个警告 不知道那里出问题了额
求高人指点