Cov txheej txheem:
- Kauj ruam 1: Yuav tsum tau ua
- Kauj Ruam 2: Tsim Tus Programmer
- Kauj Ruam 3: Txhim Kho Programmer Software
- Kauj ruam 4: Programming Chip
- Kauj ruam 5: Sib dhos
- Kauj Ruam 6: Piav Qhia
- Kauj Ruam 7: Cov Khoom Siv Ntxiv
Video: Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino): 7 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
8051 (tseem hu ua MCS-51) yog MCU tsim los ntawm 80's uas tseem nyiam niaj hnub no. Niaj hnub nimno 8051-sib xws microcontrollers muaj los ntawm ntau tus neeg muag khoom, hauv txhua daim duab thiab qhov ntau thiab tsawg, thiab nrog ntau yam khoom siv ib puag ncig. Hauv cov lus qhia no peb yuav saib AT89C2051 MCU los ntawm Atmel.
AT89C2051 yog qhov me me (2Kbyte Flash, 128byte RAM), pheej yig (~ $ 1.40 ib nti) microcontroller. Qhov:
- 2.7-6V ua haujlwm
- 15 I/O kab
- 2 timers (16 ntsis)
- Sab hauv thiab sab nrauv cuam tshuam
- UART
- On-chip analog sib piv
- Mus txog 2MIPS nrog 24MHz moos
Kauj ruam 1: Yuav tsum tau ua
Yuav tsum:
- Linux PC (yuav tsum tau software: Arduino IDE, git, ua, sdcc)
- Arduino UAS
- AT89C2051 nti (pob DIP20)
- 20-pin ZIF qhov (socket)
- Optocoupler (nyiam dua MOSFET-tso zis)
- Arduino prototyping ntaub thaiv npog
- 12V fais fab mov
- 5V fais fab mov
- 16MHz siv lead ua oscillator
- 2 x 30pF capacitor
- 100 nF capacitor
- Diode (ex: 1N400X)
- Resistors (1K, 3K3)
- Protoboard
- Cov neeg dhia
- Tooj hlau
Txheeb xyuas cov software xav tau:
qho python3
uas ua rau sdcc twg git
Kauj Ruam 2: Tsim Tus Programmer
Tshooj lus no yuav luv luv, raws li kuv tau tsim kuv lub phiaj xwm phiaj xwm qee lub sijhawm dhau los. Kuv tau txuas cov schematic thiab cov duab ntawm pawg thawj coj ua ke. PDF ntawm cov txheej txheem tuaj yeem pom hauv cov chaw cia khoom.
Koj yuav tsum tau npaj cov programmer board:
1. Clone lub chaw cia khoom.
git clone
2. Qhib AT89C2051_programmer/AT89_prog/AT89_prog.ino cov ntaub ntawv hauv Arduino IDE.
3. Tsim thiab xa cov duab kos los ntawm Arduino IDE.
Kauj Ruam 3: Txhim Kho Programmer Software
1. Tsim kom muaj nab hab sej virtual puag ncig.
python3 -m venv cov
. venv/bin/qhib
2. Nruab at89overlord. at89overlord yog Open Source programmer rau AT89C2051 nti sau los ntawm kuv. Nws qhov chaws tuaj yeem pom ntawm no.
pip nruab at89overlord
3. Txheeb xyuas kev teeb tsa.
at89overlord -h
Kauj ruam 4: Programming Chip
1. Clone txoj haujlwm ntsais muag yooj yim.
cd ~ ib
git clone https://github.com/piotrb5e3/hello-8051.git cd nyob zoo -8051/
2. Tsim daim ntawv thov.
ua
3. Txuas Arduino mus rau PC, txuas lub 12V khoom, tso AT89C2051 nti hauv ZIF qhov (socket).
4. Nrhiav Arduino qhov chaw nres nkoj txuas.
ls /dev /tty*
5. Upload ua IntelHex cov ntaub ntawv rau lub nti. Yog tias koj qhov chaw nres nkoj Arduino txawv los ntawm /dev /ttyACM0 koj yuav tsum dhau tus nqi raug nrog -p hais kom ua kab kab lus.
at89overlord -f./hello.ihx
Kauj ruam 5: Sib dhos
Sib dhos lub Circuit Court raws li schematic. Cov ntawv PDF tuaj yeem pom nyob hauv qhov chaw cia khoom.
Koj yuav tsum pom lub teeb ntsuab ntsuab nrog qhov ib puag ncig ntawm 0.5Hz.
Kauj Ruam 6: Piav Qhia
#suav nrog
#suav nrog
Peb pib los ntawm suav nrog AT89X051 header los ntawm sdcc. Nws muaj macros rau kev cuam tshuam nrog cov npe xws li yog lawv hloov pauv. Peb kuj suav nrog stdint.h uas muaj cov ntsiab lus ntawm uint8_t thiab uint16_t hom sib xyaw.
Piv txwv tias yog oscillator yog 16MHz
#define INTERRUPTS_PER_SECOND 5208
Kev cuam tshuam tshwm sim thaum Timer0 dhau los. Nws tau teeb tsa ua ib zaug 8bit timer, yog li qhov no tshwm sim txhua 2^8 tus txheej txheem ua haujlwm. Ib lub tshuab ua haujlwm siv sijhawm 12 teev mus, thiab yog li peb tuaj txog ntawm 16000000/12/2^8 = 5208.33333.
volatile uint8_t led_state = 0;
volatile uint16_t timer_counter = INTERRUPTS_PER_SECOND;
Peb tshaj tawm txoj kev tswj hwm lub xeev thiab cuam tshuam cov kev hloov pauv ntawm cov txee.
void Timer0_ISR (tsis muaj dab tsi) _ cuam tshuam (1) {
timer_counter--; yog (timer_counter == 0) {led_state =! led_state; timer_counter = INTERRUPTS_PER_SECOND; }}
Txhua lub sijhawm Timer0 dhau los ntawm lub txee tau qis dua. Yog tias nws sib npaug rau xoom nws rov pib dua, thiab lub xeev coj tau hloov pauv. Qhov no tshwm sim ib puag ncig ib zaug thib ob, ua rau ~ 0.5Hz LED ntsais ntsais zaus.
int lub ntsiab () {
TMOD = 0x3; // Timer hom - 8bits, tsis muaj prescaler freq = OSCFREQ/12/2^8 TL0 = 0; // Tshem cov txee TH0 = 0; // Tshem tawm npe TR0 = 1; // Teem caij timer kom khiav. ET0 = 1; // Teeb cuam tshuam. EA = 1; // Teeb tsa kev cuam tshuam thoob ntiaj teb. thaum (1) {yog (led_state) {P1 = 0xFF; } lwm {P1 = 0x00; }}}
Peb teeb tsa lub sijhawm teev sijhawm thiab tos hloov pauv hauv kev coj ua lub xeev tswj kev sib txawv. TMOD yog lub sijhawm timer tswj kev sau npe. TL0 thiab TH0 yog Timer0 tswj cov npe. ET0 yog lub peev xwm-timer0 ntsis hauv lub sijhawm tswj npe (TCON). TR0 thiab EA yog cov khoom me me hauv kev cuam tshuam qhib npe (IE).
Kauj Ruam 7: Cov Khoom Siv Ntxiv
- AT89C2051 cov ntawv:
- Cov cuab yeej me C Compiler (sdcc):
- 8051 cov peev txheej:
- AT89C2051 tus khoos phis tawj cia:
- nyob zoo-8051 repository:
Pom zoo:
LED Qhov Taw Qhia Qhov Taw Qhia Tus Menyuam: 5 Kauj Ruam (nrog Duab)
LED Qhov Taw Qhia Qhov Taw Qhia Tus dev: Kuv ib txwm coj kuv tus dev Rusio mus taug kev thaum lub hnub poob qis kom nws tuaj yeem ua si yam tsis tau kub heev. Qhov teeb meem yog tias thaum nws tawm ntawm txoj hlua qee zaum nws tau zoo siab heev thiab ua haujlwm ntau dua li nws yuav tsum thiab nrog lub teeb qis thiab lwm tus dev
Yuav Ua Li Cas Thiaj Li Taw Qhia Qhov Taw Qhia: 6 Kauj Ruam
Yuav Ua Li Cas Thiaj Li Qhia Tus Kheej: Lub hom phiaj tseem ceeb ntawm daim ntawv thov no yog txhawm rau ntsuas qhov hnyav ntawm ib yam khoom tom qab ntawd qhia nrog lub tswb nrov thaum muaj qhov hnyav dhau. Cov tswv yim ntawm lub kaw lus los ntawm lub xov tooj ntawm tes. Kev tawm tswv yim yog lub teeb liab sib piv uas tau nthuav dav los ntawm qhov sib txawv
Taw qhia rau Programming Raspberry Pi Tsis Siv Coding: 3 Kauj Ruam
Taw qhia rau Txoj Haujlwm Raspberry Pi Tsis Muaj Coding: Nyob zoo, cov lus qhia no yuav qhia koj yuav ua li cas tig koj li Raspberry Pi mus rau hauv lub cuab yeej siv lub tshuab ua haujlwm tau zoo sib xws nrog cov lus qhia ua ntu lus programming rau PLCs hu ua Function Block Diagram (ib feem ntawm IEC 61131-3 tus qauv). Qhov no tuaj yeem yog
Kev Taw Taw Taw Tswj 5 Gallon Dej Dispenser: 3 Kauj Ruam
Tus Kheej Tus Kheej Tus Kheej 5 Gallon Dej Tso Dej: Hauv qee lub tebchaws zoo li qhov kuv nyob (Qaib ntxhw), peb muaj teeb meem nrog lub twj tso kua mis kom xa dej tawm ntawm lub ntim. Qee lub twj tso kua mis yog qhov nyuaj thiab cov menyuam yaus muaj teeb meem nrog kev muab lub zog xav tau. Yog li kuv xav txog kev siv ko taw
Taw qhia rau Kev Paub Lub Suab Nrog Elechouse V3 thiab Arduino.: 4 Cov Kauj Ruam (nrog Duab)
Taw qhia rau Kev Paub Lub Suab Nrog Elechouse V3 thiab Arduino.: Nyob zoo …! Lub suab suab thev naus laus zis tau nyob ntawm no ob peb xyoos dhau los. Peb tseem nco tau qhov kev zoo siab uas peb muaj thaum tham nrog thawj Siri tau qhib lub iPhone. Txij thaum ntawd los, lub suab hais kom ua cov cuab yeej tau nce mus rau qib siab heev beyo