我一直在尝试将程序烧录到 ATtiny2313A-PU 中,并将我的 Arduino Uno R3 用作程序员。首先,我尝试从 Arduino IDE 1.0.1 (Windows 7) 对其进行编程,它似乎上传了草图,但闪烁程序不起作用。然后我找到了Michael Holachek 的教程并按照他的指示进行操作:
- 将 ArduinoISP 草图上传到我的 Arduino Uno
- 将电路连接到面包板上
- 在我的 Windows 7 上安装了 WinAVR。
- 下载 Michael 的模板文件(Makefile 和 main.c)并编辑 Makefile 以匹配我的设置(外部 8 MHz 晶体)。我使用这个在线保险丝计算器来获得正确的保险丝参数。
- 然后,在 cmd.exe 中,将目录更改为我保存 Makefile 和 main.c 并运行“make flash”的目录
生成文件
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
主程序
下面是我得到的输出:
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 上的保险丝弄坏。如果是这样的话,我想我将不得不建造这个 AVR 救援盾牌。也许 Makefile 配置不正确?如何识别问题?如何检查芯片是否还活着?