Cov txheej txheem:

Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino: 7 Kauj Ruam
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino: 7 Kauj Ruam

Video: Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino: 7 Kauj Ruam

Video: Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino: 7 Kauj Ruam
Video: qaib zuav ceg yog vim li cas thiab yuav ua li cas? 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino
Yuav Ua Li Cas Program AVR (arduino) Nrog Lwm Arduino

Cov ntawv qhia no muaj txiaj ntsig yog tias:

* koj tau txais koj cov arduino nrog atmega168 thiab koj yuav atmega328 ntawm koj lub khw hluav taws xob hauv zos. Nws tsis muaj arduino bootloader * koj xav ua qhov haujlwm uas tsis siv arduino - tsuas yog ib qho AVR nti ib txwm (zoo li USBTinyISP) - koj muaj qhov huv huv attiny2313/attiny48 thiab lwm yam uas koj xav kom hlawv cov firmware ntawm. Feem ntau koj yuav tsum muaj ISP (Hauv System Programmer) zoo li USBTinyISP los teeb tsa koj lub nti tshiab. Muaj cov arduino koj tuaj yeem qhia nws ua tus programmer ua tsaug rau txoj haujlwm zoo ua los ntawm Randall Bohn. Nws tsim Mega -ISP - daim duab arduino uas ua haujlwm zoo li tus programmer.

Kauj Ruam 1: Koj Xav Tau Dab Tsi?

Koj Xav Tau Dab Tsi?
Koj Xav Tau Dab Tsi?

* ua haujlwm Arduino (lossis clone - kuv tab tom siv BBB - BareBonesBoard thiab RBBB - RealBareBonesBoard los ntawm ModernDevices) * lub nti uas koj xav tau rau program (kuaj nrog atmega8, atmega168, atmega368, attiny2313, attiny13) * ib lub rooj tsavxwm nrog ISP header * 3 leds + 3 resistors * breadboard xov hlau

Kauj Ruam 2: Ua Mega-isp Programmer ntawm Breadboard

Ua Mega-isp Programmer ntawm Breadboard
Ua Mega-isp Programmer ntawm Breadboard
Ua Mega-isp Programmer ntawm Breadboard
Ua Mega-isp Programmer ntawm Breadboard
Ua Mega-isp Programmer ntawm Breadboard
Ua Mega-isp Programmer ntawm Breadboard

Muaj ob txoj hauv kev los txuas koj Arduino rau program chip.

Koj tuaj yeem ntsaws koj lub avr nti rau ntawm lub khob cij thiab txuas 5v thiab GND rau tus lej sib xws (txheeb xyuas cov ntawv teev tseg!) + Rub tawm tus tiv thaiv kom rov pib dua thiab xaim pins los ntawm koj arduino rau lub nti. Cov no yog cov kab ntawm Arduino thiab lawv cov haujlwm 13 - SCK 12 - MISO 11 - MOSI 10 - RST (Rov Pib dua) Los yog koj tuaj yeem ua 2x3pin ISP header uas koj tuaj yeem ntsaws rau hauv pawg thawj coj uas muab ib qho (lwm pawg thawj coj arduino). Tus pinout rau ISP lub taub hau nyob ntawm daim duab thib peb Muaj 3 leds los qhia qhov xwm txheej ntawm tus programmer. tus pin 9 - xiav coj - nws lub suab hnov ntawm tus programmer. tus pin 8 - coj liab - qhia qhov yuam kev tus pin 7 - ntsuab ntsuab - qhia tias qhov kev zov me nyuam tau ua qhov chaw (kuv tau tub nkeeg ces kuv tsis phim cov xim hauv kuv teeb tsa) Ntawm no yog cov duab kos hauv Fritzing Koj tuaj yeem ua tau MEGA-isp ntaub thaiv npog. Yaroslav Osadchyy tsim daim ntaub thaiv hauv dav dawb hau. Koj tuaj yeem tau txais cov ntaub ntawv dav dav ntawm nws lub xaib:

Kauj Ruam 3: Upload Sketch

Rub tawm daim Sketch
Rub tawm daim Sketch

Rub tawm daim duab kos los ntawm mega-isp google code. (Avrisp.03.zip thaum lub sijhawm sau ntawv). Unpack nws thiab khiav arduino lub tswv yim thiab qhib avrisp.pde. Rub nws mus rau koj lub rooj tsav xwm arduino. Lub plawv dhia coj yuav tsum pib ntaus.

Kauj Ruam 4: Siv Nrog Avrdude

Siv Nrog Avrdude
Siv Nrog Avrdude

Txhawm rau siv nrog avrdude (thiab txhua GUIs uas siv nws) koj yuav tsum xaiv tus 'avrisp' programmer. qhov muaj kev nyab xeeb tshaj plaws yog 19200.

Txhawm rau sim koj qhov tshiab atmega168 los ntawm kab lus sim: $ avrdude -p m168 -P /dev /ttyUSB0 -c avrisp -b 19200 /dev /USB0 yog qhov chaw nres nkoj uas arduino txuas nrog kuv lub thawv linux (koj yuav yog com5). Qhov no tuaj yeem tshawb xyuas hauv arduino IDE hauv Cov Cuab Yeej -> Serial Port. Koj yuav tsum tau txais: [kabturek@hal -9000 ~]# avrdude -p m168 -P /dev /ttyUSB0 -c avrisp -b 19200 avrdude: AVR ntaus ntawv pib thiab npaj los lees txais cov lus qhia Nyeem | ############################################# | 100% 0.13s avrdude: Kos npe ntaus ntawv = 0x1e9406 avrdude: safemode: Fuses OK avrdude ua tiav. Ua tsaug. Qhov ntawd txhais tau tias txhua yam zoo. Yog tias koj tau txais qhov yuam kev - txheeb xyuas cov kauj ruam kawg.

Kauj Ruam 5: Hlawv USBtinyISP Firmware rau Attiny2313

Hlawv USBtinyISP Firmware rau Attiny2313
Hlawv USBtinyISP Firmware rau Attiny2313
Hlawv USBtinyISP Firmware rau Attiny2313
Hlawv USBtinyISP Firmware rau Attiny2313
Hlawv USBtinyISP Firmware rau Attiny2313
Hlawv USBtinyISP Firmware rau Attiny2313

USBTinyISP yog tus programmer zoo los ntawm LadyAda uas pheej yig tiag tiag - 22 $. Kuv muaj qhov tsis txaus ntseeg 2313 thiab qee qhov yog li kuv txiav txim siab ua ib tus kheej. Yog tias koj tsis muaj kev paub dhau los ua PCB Kuv qhia koj yuav cov khoom ua rau nws zoo dua li koj tuaj yeem ua rau koj tus kheej:). Yam tsawg kawg yuav PCB yog tias koj xav tsim ib qho. Koj tuaj yeem tau txais nws los ntawm Adafruit. Txuas ATtiny2313 Hauv daim duab kawg koj tuaj yeem pom attiny2313 nrog cov pins siv rau ISP liab. Daim duab yog los ntawm LadyAda avr qhia. Hlawv cov firmware: Unpack USBTinyISP firmware. Mus rau spi dir thiab khiav $ avrdude -p pt2313 -P /dev /ttyUSB0 -c avrisp -b 19200 los tshuaj xyuas yog tias txhua yam zoo nrog lub nti. Tam sim no teeb tsa fuses: $ avrdude -P /dev /ttyUSB0 -c avrisp -b 19200 -pt2313 -U hfuse: w: 0xdf: m -U lfuse: w: 0xef: m Tam sim no koj yuav tsum txuas 12mhz sab nraud oscillator rau lub nti. Thiab hlawv cov firmware: $ avrdude -B 1 -pt2313 -U flash: w: main.hex -P /dev /ttyUSB0 -c avrisp -b 19200 Voila. Koj tus attiny2313 muaj USBTinyISP firmware.

Kauj Ruam 6: Hlawv Arduino Bootloader

Hlawv Arduino Bootloader
Hlawv Arduino Bootloader
Hlawv Arduino Bootloader
Hlawv Arduino Bootloader
Hlawv Arduino Bootloader
Hlawv Arduino Bootloader

Txuas kuv dag me ntsis ua rau kuv siv RBBB los ua kom yooj yim kev sib txuas. Schema nyob ntawm daim duab #2. Yog tias koj siv 2 arduinos siv daim duab #3 thiab txuas tus ISP tus pin rau ICSP 2x3 lub taub hau ntawm tus thib ob (qhev) arduino. Xaiv txuas lub zog usb rau thawj pawg thawj coj. Txoj hauv kev GUI Qhov no yog qhov ua rau me ntsis ua rau koj tsis tuaj yeem siv Cov Cuab Yeej-> Hlawv Bootloader-> w/ AVR ISP ua rau lub nrawm nrawm yog loj heev rau mega-isp. Nrhiav avrdude.conf uas los nrog arduino IDE (hauv arduino/kho vajtse/cuab yeej/avrdude.conf) thiab hloov thaj tsam rau avrisp programmer los ntawm 115200 txog 19200 (nyob ib ncig ntawm kab 312) Nrhiav thiab hloov pauv hauv avrdude.conf programmer id = "avrisp"; desc = "Atmel AVR ISP"; baudrate = 115200; # default yog 115200 hom = stk500;; rau: programmer id = "avrisp"; desc = "Atmel AVR ISP"; baudrate = 19200; # default yog 115200 hom = stk500;; Tam sim no koj tuaj yeem siv Cov Cuab Yeej -> Hlawv Bootloader -> w/AVR ISP (tom qab koj xaiv lub rooj tsav xwm kom raug los ntawm Cov Ntawv Qhia Cuab Yeej) Commanline Koj kuj tseem tuaj yeem siv kab hais kom ua: Hloov kho arduino/hardware/bootloaders/atmega/Makefile thiab hloov ISPTOOL/PORT /SPEED rau: # nkag mus rau qhov ntsuas rau avrdude isp tool ISPTOOL = avrisp ISPPORT = /dev /ttyUSB0 ISPSPEED = -b 19200 tsis yog koj tuaj yeem sau $ ua diecimila_isp mus hlawv fuses thiab bootloader. Test Tam sim no txuas koj tshiab arduino rau usb thiab hlawv blinky!

Kauj ruam 7: Troubleshooting

Teeb meem
Teeb meem

Avrdude tsis raug: avrdude: ser_open (): qhib tsis tau ntaus ntawv "/dev/ttyUSB0": Tsis muaj cov ntaub ntawv lossis cov npe Koj muaj qhov chaw nres nkoj tsis raug (-P) tau teev tseg lossis koj cov arduino tsis txuas nrog. kos qhov txuas txuas avrdude: Kos npe ntaus ntawv = 0x000000 avrdude: Yikes! Kos npe ntaus ntawv tsis raug Txheeb ob qhov kev sib txuas thiab sim dua, lossis siv -F txhawm rau hla daim tshev no. Qhov no yog yam yuam kev dav. Koj tus nti tsis tau lees paub. Txheeb xyuas qhov kev sib txuas ntawm lub rooj tsavxwm (GND/5V txuas nrog tus pin?) Koj yuav tau txais qhov yuam kev no thaum koj lub nti tau teeb tsa los siv tus oscillator sab nraud thiab nws tsis ua haujlwm (tsis muaj ib qho lossis nws tsis yog oscillating properl - 22pf lub kaus mom ploj lawm?)

Pom zoo: