Cov txheej txheem:

Yuav Teeb Li Cas AVR Txoj Haujlwm Ib puag ncig ntawm Linux: 5 Kauj Ruam
Yuav Teeb Li Cas AVR Txoj Haujlwm Ib puag ncig ntawm Linux: 5 Kauj Ruam

Video: Yuav Teeb Li Cas AVR Txoj Haujlwm Ib puag ncig ntawm Linux: 5 Kauj Ruam

Video: Yuav Teeb Li Cas AVR Txoj Haujlwm Ib puag ncig ntawm Linux: 5 Kauj Ruam
Video: Data Science with Python! Analyzing File Types from Avro to Stata 2024, Kaum ib hlis
Anonim
Yuav Ua Li Cas Teeb AVR Programming Ib puag ncig ntawm Linux
Yuav Ua Li Cas Teeb AVR Programming Ib puag ncig ntawm Linux

Yog tias koj xav tau program AVR microcontrollers ntawm Windows koj muaj Studio tab sis ntawm Linux txhua yam peb muaj yog Dude.

AVRDUDE yog kab hais kom ua kab ke rau program AVR chips, nws tuaj yeem ua rau me ntsis kom teeb tsa thaum xub thawj.

Ua ntej kuv yuav txhim kho tag nrho AVRDUDE thiab txhua qhov yuav tsum tau muaj kev vam khom ces kuv yuav tsim tsab ntawv BASH uas yuav pab tau hauv kev sau ntawv

Kauj Ruam 1: Tau Koj Tus Compiler thiab Lwm Yam Cuab Yeej

Hauv lwm qhov rau program AVR chips koj xav tau tus tshwj xeeb tus neeg sau npe hu ua gcc-avr thiab lwm yam cuab yeej zoo li binutils-avr, avr-libc, gdb-avr kawg tab sis tsis yog avrdude tsawg kawg.

sudo apt-tau nruab gcc-avr binutils-avr avr-libc gdb-avr avrdude

Kauj Ruam 2: Tsim Tus Qauv

Tsim Tus Qauv
Tsim Tus Qauv

Yog tias koj qhib qhov kos duab tshiab hauv arduino koj tau txais tus qauv qauv uas muaj ob txoj haujlwm, qhov no txuag koj ntau lub sijhawm.

AVRDUDE siv C thiab nws tuaj yeem yog qhov txaus siab me ntsis kom ib txwm tsim txoj hauv kev tseem ceeb txhua lub sijhawm koj xav tau tus lej, yog li kuv yuav tsim tus qauv AVR.

kov ~/Templates/AVR.c

Siv qhov kov hais kom ua los ua cov ntaub ntawv khoob hauv Templates nplaub tshev.

vi ~/Templates/AVR.c

qhib cov ntawv nrog koj cov ntawv nyeem uas kuv nyiam tshaj, kuv siv vi.

#define F_CPU 16000000L

#include #include int main () {thaum () {} rov qab 0; }

Ntaus cov cai saum toj no thiab khaws cov ntawv. Cov cai no yuav ua haujlwm raws li peb tus qauv.

Nco tseg: Kuv teeb tsa kuv lub moos zaus li 16000000, koj tuaj yeem teeb tsa koj li ib txwm muaj tej zaum yog 8000000.

Kauj Ruam 3: Tsim Cov Ntawv Tshiab

Tam sim no peb muaj tus qauv rau peb cov lej AVR, txhua yam peb yuav tsum tau ua yog tsim cov ntawv tshiab. Kuv yuav tsim cov lus txib bash uas yuav siv nyob rau hauv ib qho kev sib cav (lub npe cov ntaub ntawv) tom qab ntawd tsim cov ntawv ntawd muaj AVR tus qauv.

cia ua cov ntaub ntawv khoob hu ua "tsim"

kov tsim

hloov cov ntawv tso cai vim qhov no yuav yog tsab ntawv BASH

chmod 755 tsim

Qhib "tsim" nrog koj cov ntawv sau. Tam sim no cia hloov "tsim", ntxiv cov lus txib hauv qab no kab ntawm kab.

#!/bin/tsoo

Nov yog txoj hauv kev rau tus neeg txhais lus rau "tsim" uas yog bash.

cp ~/Qauv/AVR.c/tsev/$ USER

Qhov no luam peb cov ntaub ntawv tus qauv rau cov neeg siv hauv tsev.

mv ~/AVR.c $ 1

Nco ntsoov kuv tau hais tias "tsim" siv rau hauv ib qho kev sib cav, $ 1 txhais tau tias thawj qhov kev sib cav ntawm peb cov lus txib qhov kev sib cav no yog lub hom phiaj cov ntaub ntawv, qhov kawg uas peb xav tau yog ntau cov ntaub ntawv muaj tib lub npe. Cov lus txib hloov npe lub npe filename rau peb qhov kev sib cav.

vi $ 1 ib

Qhov no yog nyob ntawm yeem tab sis nws yuav zoo qhib peb cov ntawv, tam sim tom qab peb tau tsim nws.

Peb tau ua tiav nrog kev kho tsim, txuag nws thiab kaw nws.

Nov yog qhov piv txwv ntawm kev tsim hauv kev nqis tes ua.

./create blink.c

Qhov no tsim cov ntaub ntawv hu ua blink.c, cov ntawv no yuav tsum muaj tus qauv ntawm AVR.c.

Kauj Ruam 4: Cia Peb Khiav

Peb yuav tsum tsim lwm tsab ntawv bash hu ua "khiav", tsab ntawv no yuav siv 3 qhov kev sib cav (avr microcontroller peb tab tom siv, lub npe thiab tus programmer)

Wb coj nws kab ntawm kab.

#!/bin/tsoo

peb shebang

avr -gcc -Wall -g -0s -mmcu = $ 1 -o $ 2.bin $ 2.c

Cov lus txib saum toj no ua raws peb cov cai, '$ 1' yog peb thawj qhov kev sib cav uas yog microcontroller peb tab tom ua haujlwm. $ 2 yog peb qhov kev sib cav zaum thib ob uas yog lub npe ntaub ntawv.

avr -objcopy -j.text -j.data -O ihex $ 2.bin $ 2.hex

Qhov no hloov peb cov ntawv ua tiav rau hex.

avrdude -p $ 1 -c $ 3 -U nyem: w: $ 2.hex -P usb

Tam sim no avrdude hlawv cov cai rau hauv AVR nti. $ 3 yog peb qhov kev sib cav zaum thib 3 uas yog tus programmer peb tab tom siv.

Txuag cov ntaub ntawv "khiav"

muab nws ua kev tso cai

chmod 755 ua

Tam sim no cia peb sim nws. Cia peb hais tias peb xav upload blink.c thiab peb tab tom siv lub rooj sib tham arduino ncaj qha, peb kuj tseem siv tus programmer usbasp. Nov yog qhov peb siv tsab ntawv "run".

./run atmega328p ntsais USBasp

Arduino board muaj atmega328p nti, koj tuaj yeem siv ib qho AVR microcontroller uas koj xaiv.

Qhov kev sib cav zaum thib ob yog koj lub npe ntawv, tab sis lub sijhawm no tsis ntxiv cov ntawv txuas ntxiv cov ntawv ua haujlwm.

Tom qab ntawd peb muaj qhov kev sib cav zaum thib peb uas yog tus programmer koj siv, kuv tab tom siv USBasp programmer.

Kauj Ruam 5: Xaus

Nov yog txoj hauv kev zoo ntawm kev siv koj li kev paub avr, koj tuaj yeem txav cov ntaub ntawv bash "tsim" thiab "khiav" mus rau "~/.local/bin" yog li koj tuaj yeem siv cov ntawv sau los ntawm cov ntawv teev npe uas koj xaiv.

Pom zoo: