我一直在努力将程序刻录到ATtiny2313A-PU,我的Arduino Uno R3用作程序员。 首先,我尝试从Arduino IDE 1.0.1(Windows 7)进行编程,它看起来像是草图,但是眨眼程序没有用。 然后我找到Michael Holachek's tutorial并按照他的指示行事:
生成文件
DEVICE = attiny2313a
CLOCK = 8000000
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
以下是我得到的输出:
C:\Users>cd /D D:\electronics
D:\electronics>cd nikon/mi
D:\electronics\nikon\mi>make flash
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny2313a -c main.c -o main.o
main.c:6: error: stray '\342' in program
main.c:6: error: stray '\200' in program
main.c:6: error: stray '\250' in program
main.c: In function 'main':
main.c:9: error: stray '\342' in program
main.c:9: error: stray '\200' in program
main.c:9: error: stray '\250' in program
make: *** [main.o] Error 1
我怀疑我可能会在Attiny 2313a上使用保险丝。如果是这种情况,我想我必须建立this AVR rescue shield。 也许Makefile配置不正确? 我该如何识别问题?如何检查芯片是否还活着?
答案 0 :(得分:3)
你在那里遇到编译错误。我会检查main.c的内容,看看编译器要求你检查的内容。它看起来像在代码的复制和粘贴中,丢失了一些东西。还
PORTD ^= (1 << PD6); // toggle PD6
可以替换为
PIND = (1 << PD6); // or _BV(PD6), since you should be using avr-libc anyway.
根据Atmel的数据表。
答案 1 :(得分:0)
DEVICE = attiny2313 -F
中添加了键,我的attiny2313a编程成功了!
TRON,谢谢你指点我的main.c!不幸的是,我无法回答你的答案,因为我的声誉是11。
我仍然想知道那些方形角色怎么能到达那里?