2013-02-18 102 views
1

今天我终于设法通过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 
} 

回答

0

事实证明,原因是这是在Makefile中添加了 “F” 键使AVRDUDE认为的ATtiny2313A是实际上是一个attiny2313(重写签名检查)。这很奇怪,但是在芯片的第一次编程之后必须删除“-F”键。 我想这也适用于,也等同于碱的AVR芯片其他新的修改(AR父?)修饰但具有各种后缀添加到他们的名字(例如“的ATtiny2313A”或“atmega168p”)

大二芯片编程后的第一个

DEVICE = attiny2313 -F 

但是,:当微控制器进行编程的第一次,而AVRDUDE无法识别芯片,该-F键应该芯片的名称后添加时间,-F密钥必须被删除,否则将不可能再次编程芯片。

1

请为了芯片的好处,请不要在avrdude上使用-F。

您在编写tinyAVR时遇到问题的原因是您正在给avrdude输入错误的零件编号。编程ATtiny2313的正确参数是-pt2313 [或者只是使用部分t2313]。使用-F可以继续砖化你的芯片,尤其是因为你正在给它充电[在某些情况下,使用高压编程器可以恢复砖块芯片,这取决于熔断器的设置。

有关AVRDUDE的更多信息,请阅读其说明书页

 -p partno 
       This is the only option that is mandatory for every invocation of avrdude. It specifies the type of the MCU connected to the program‐ 
       mer. These are read from the config file. If avrdude does not know about a part that you have, simply add it to the config file (be 
       sure and submit a patch back to the author so that it can be incorporated for the next version). See the sample config file for the 
       format. Currently, the following MCU types are understood: 

       Option tag Official part name 
       ...snip... 
       t2313  ATtiny2313 
       ...snip... 

的操作返回的的ATtiny2313A设备的签名是相同的,但AVRDUDE声称不去跟2313A。如果不需要它们,请关闭熔丝编程,然后在没有-F选项的情况下进行测试。干杯。

PS。海湾合作委员会对你的错误原因是因为

-Fdir 
     Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with 
     those specified by -I options and are scanned in a left-to-right order. 

你给它传递一个参数,它不知道该如何处理它。为了解决这个问题的东西,在你的Makefile,添加

PROGDEV=t2313 

,改变你的AVRDUDE调用使用PROGDEV,而不是DEVICE

此外,在先前的答案,说

PORTD ^= (1 << PD6); 

可以通过

PIND = (1 << PD6); 

后者编译只是一个指令,相比两个三个指令,你拥有它更换。这节省了芯片上的代码空间,并使代码运行更快。有关详细信息,请参阅Atmel数据表。

+0

哇!感谢您的详细解答,TRON! – Olexiy 2013-02-19 15:07:18