Cov txheej txheem:

Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino): 7 Kauj Ruam (nrog Duab)
Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino): 7 Kauj Ruam (nrog Duab)

Video: Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino): 7 Kauj Ruam (nrog Duab)

Video: Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino): 7 Kauj Ruam (nrog Duab)
Video: QHIA QHOV TSEEB - KUB VAJ LOOG TSUA NEW MUSIC VIDEO 2022 2024, Hlis ntuj nqeg
Anonim
Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino)
Taw qhia rau 8051 Programming Nrog AT89C2051 (Qhua Qhua: Arduino)

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 muaj
Yuav tsum muaj

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

Tsim tus Programmer
Tsim tus Programmer
Tsim tus Programmer
Tsim tus Programmer
Tsim tus Programmer
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

Txhim kho Programmer Software
Txhim kho Programmer Software
Txhim kho Programmer Software
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

Programming Chip
Programming Chip
Programming Chip
Programming Chip
Programming Chip
Programming Chip
Programming Chip
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

Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke
Los ua ke

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

Kev piav qhia Code
Kev piav qhia Code

#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: