今天我终于设法通过Arduino Uno编写attiny2313a。这是一个测试闪烁程序。上传后,我看到LED闪烁8秒延迟而不是1秒,所以我决定改变Makefile和main.c中的时钟设置,并再次烧录芯片。 因此,我只将Makefile和main.c中的8000000更改为1000000,并在cmd(windows shell)中运行make flash
。下面是输出:编译.c到.hex - cc1.exe:错误:avr25:没有这样的文件或目录
avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny2313 -F -c main.c -o main.o
cc1.exe: error: avr25: No such file or directory
make: *** [main.o] Error 1
为什么会出现这个错误?为什么我只能编译和刻录该程序一次? 我没有删除,也没有添加新的东西。其实我除了那些时钟设置以外什么都没碰。但即使当我回到原始设置(8000000),我仍然有同样的错误。
我的Makefile
DEVICE = attiny2313 -F
CLOCK = 1000000
PROGRAMMER = -c arduino -P COM5 -b 19200
OBJECTS = main.o
FUSES = -U lfuse:w:0x5e:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
######################################################################
######################################################################
# Tune the lines below only if you know what you are doing:
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: main.hex
.c.o:
$(COMPILE) -c $< -o [email protected]
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o [email protected]
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
.c.s:
$(COMPILE) -S $< -o [email protected]
flash: all
$(AVRDUDE) -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
bootloadHID main.hex
clean:
rm -f main.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS)
main.hex: main.elf
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
# Targets for code debugging and analysis:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c
我的main.c
#define F_CPU 1000000 // CPU frequency for proper time calculation in delay function
#include <avr/io.h>
#include <util/delay.h>
int main (void){
DDRD |= (1 << PD6); // make PD6 an output
for(;;){
PORTD ^= (1 << PD6); // toggle PD6
_delay_ms(1000); // delay for a second
}
return 0; // the program executed successfully
}
哇!感谢您的详细解答,TRON! – Olexiy 2013-02-19 15:07:18