今天我终于设法通过 Arduino Uno 对 attiny2313a 进行了编程。这是一个测试眨眼程序。上传后,我看到 LED 闪烁 8 秒而不是 1 秒,所以我决定更改 Makefile 和 main.c 中的时钟设置并再次烧录芯片。所以,我只在 Makefile 和 main.c 中将 8000000 更改为 1000000 并make flash
在 cmd (windows shell)中运行。下面是输出:
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 $@
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-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 $@
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
}