|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2007-10-11 17:19:07
|
显示全部楼层
#include <avr/io.h>
// 函数声明
static void Delay(void);
static void Port_Init(void);
int main(void)
{
unsigned char loop;
unsigned char Display_Code[8]=
{
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};
Port_Init();
while (1)
{
for (loop=0; loop<8; loop++)
{
PORTB = Display_Code[loop];
Delay();
}
}
}
void Delay(void)
{
unsigned char x, y;
for (x=0; x<255; x++)
{
for (y=0; y<255; y++);
for (y=0; y<255; y++);
}
}
void Port_Init(void)
{
DDRB = 0xff; // 置PORTB端口为输出方向
PORTB = 0xff; // portb所有端口输出高电平
}
> "make.exe" all
-------- begin --------
avr-gcc (GCC) 3.4.1
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: main.c
avr-gcc -c -mmcu=atmega8 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.lst -std=gnu99 -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.o.d main.c -o main.o
Linking: main.elf
avr-gcc -mmcu=atmega8 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o -std=gnu99 -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm
Creating load file for Flash: main.hex
avr-objcopy -O ihex -R .eeprom main.elf main.hex
Creating load file for EEPROM: main.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O ihex main.elf main.eep
Creating Extended Listing: main.lss
avr-objdump -h -S main.elf > main.lss
Creating Symbol Table: main.sym
avr-nm -n main.elf > main.sym
Size after:
main.elf :
section size addr
.text 172 0
.data 8 8388704
.bss 0 8388712
.noinit 0 8388712
.eeprom 0 8454144
.stab 756 0
.stabstr 1291 0
Total 2227
Errors: none
-------- end --------
> Process Exit Code: 0
象这样中同一个源文件中可以编译成功,为什么??? |
|