以avrdude讀寫atmega8之hfuse,lfuse

以arduino Uno當isp,接線方式請參閱coopermaa大的把 Arduino 當成一個 AVR ISP(In-System Programmer) 使用(2)

avr的fuse設定查詢http://www.engbedded.com/fusecalc/

①讀取ATmega8之hfuse,lfuse

avrdude -c avrisp -b 19200 -p ATmega8 -P /dev/ttyACM0 -U hfuse:r:-:h -U lfuse:r:-:h

-P後加的是arduino接電腦的com port位置,所以要視情況調整。

執行結果如下:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.06s
avrdude: Device signature = 0x1e9307
avrdude: reading hfuse memory:
Reading | ################################################## | 100% 0.02s
avrdude: writing output file "<stdout>"
0xca
avrdude: reading lfuse memory:
Reading | ################################################## | 100% 0.02s
avrdude: writing output file "<stdout>"
0xdf
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

所以hfuse是Oxca,lfuse是0xdf

avrdude -c avrisp -b 19200 -p  ATmega8 -P /dev/ttyACM0 -v

結果顯示如下

avrdude: Version 5.10, compiled on Jun 27 2010 at 00:38:29
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avrisp
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA8
         Chip Erase delay              : 10000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash         33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel AVR ISP
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA

avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

③寫入fuse,下列這行指令會將atmega8的lfuse設為0xe4,hfuse設為0xd9

avrdude -c avrisp -b 19200 -p  ATmega8 -P /dev/ttyACM0 -U lfuse:w:0xe4:m -U hfuse:w:0xd9:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x1e9307
avrdude: reading input file "0xe4"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.06s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xe4:
avrdude: load data lfuse data from input file 0xe4:
avrdude: input file 0xe4 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xd9"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.06s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd9:
avrdude: load data hfuse data from input file 0xd9:
avrdude: input file 0xd9 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

O

分類: arduino | 標籤: , | 在〈以avrdude讀寫atmega8之hfuse,lfuse〉中留言功能已關閉

Arduino ide 中之attiny13a-pu 設定

①到https://github.com/tekstop/attiny/tree/Arduino1下載attiny資料夾。

②將資料夾放到/usr/share/arduino/hardware中

③將arduino/hardware/arduino/cores/arduino/wiring.c中的第44行最後加上|| defined(__AVR_ATtiny13__)

if defined(__AVR_ATtiny24__) || defined ...  || defined(__AVR_ATtiny13__)


參考:

arduino1 branch
ATTINY13A-PU Datasheet
分類: arduino | 標籤: | 在〈Arduino ide 中之attiny13a-pu 設定〉中留言功能已關閉

鉛酸電池行動電源DIY

有時筆電要在外面用上一整天,找不到插座時很麻煩,興起用鉛酸電池DIY一個行動電源來用。構思畫圖約一天後,做出的成品。

電池選的是廣隆免加水7.2AH,才3百多元。因為筆電用的是19V,所以要用升壓模組將12V升到19V。

怕電池過放電而受損,所以在輸出入都加上電壓表,如果低於11V時就不要再放電。 diy_power1.jpg

側邊的開關,打開後輸出19V的電壓給筆電

diy_power2.jpg

右邊是鉛酸電池電壓,左邊是輸出電壓

diy_power3.jpg

升壓模組及內部的情形

diy_power4.jpg

加上個蓋子

diy_power5.jpg

成品圖

實測充到飽可以用約5小時,雖然重量和體積都不小。不過可以解我的急用。

可改良處有:

①也許下一版可以加上電壓偵測,低於11V時自動關機。
②充電不方便,要拉出電池才能充,可加一DC母座,再做一條充電線來充電。也可由此處並聯汽車的大電池,有40AH的容量,可以用上2天不必關機。
③要加進保險絲和二極體來避免反接或短路的危險,也可保護電池。

BTW,這個DIY行動電源CP值超高喔,7.2AH成本不到1000元。 O

分類: 電子 | 在〈鉛酸電池行動電源DIY〉中留言功能已關閉