同じ種類のマイコンばかりですが、少しずつライターコレクションが増えてきました。AVRマイコンのことが、うすらぼんやり掴めてきている気がします。
今回は、ATtiny26です。
Flash Programのためのピン配は以下のとおりで、VCCとGNDがマイコンを逆に挿しても動作するようになっています。なんだかピンが2つもったいない気もしますが、初心者には優しいかもしれません。
ATtiny26
+-----------+
SCLK -|1 20|-
MISO -|2 19|-
MOSI -|3 18|-
PB3 -|4 17|-
VCC -|5 16|- GND
GND -|6 15|- VCC
-|7 14|-
-|8 13|-
_____ -|9 12|-
RESET -|10 11|-
+-----------+
ではRaspberry PIをFLASHライターにしてATtiny26へHEXファイルを焼いてみます。
ブレッドボードの配線はこのとおりです。
avrdude.confはこの設定です。
pi@raspberrypi:~ $ grep 'id.*linuxgpio' -nA5 /etc/avrdude.conf 1109: id = "linuxgpio"; 1110- desc = "Use the Linux sysfs interface to bitbang GPIO lines"; 1111- type = "linuxgpio"; 1112- reset = 22; 1113- sck = 11; 1114- mosi = 10; pi@raspberrypi:~ $
プログラム一式はgithubへ登録してありますので、clone。
root@raspberrypi:~# git clone https://github.com/takkete/bread.git root@raspberrypi:~# cd bread/mcu/avr/attiny26
makeすれば、hello.cがビルドされ、HEXが生成されます。
root@raspberrypi:~/bread/mcu/avr/attiny26# make avr-gcc -O2 -mmcu=attiny26 -DF_CPU=1000000UL -c -o hello.o hello.c avr-gcc -O2 -mmcu=attiny26 hello.o -o hello avr-objcopy -j .text -j .data -O ihex hello hello.hex
HEXを書き込みます。書き込みするのもmakefileを使ってます。
root@raspberrypi:~/bread/mcu/avr/attiny26# make write
avrdude -p t26 -c linuxgpio -U flash:w:hello.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9109
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "hello.hex"
avrdude: input file hello.hex auto detected as Intel Hex
avrdude: writing flash (74 bytes):
Writing | ################################################## | 100% 0.09s
avrdude: 74 bytes of flash written
avrdude: verifying flash memory against hello.hex:
avrdude: load data flash data from input file hello.hex:
avrdude: input file hello.hex auto detected as Intel Hex
avrdude: input file hello.hex contains 74 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.07s
avrdude: verifying ...
avrdude: 74 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:17, L:E1)
avrdude done. Thank you.
root@raspberrypi:~/bread/mcu/avr/attiny26#
焼けました。

コメント