Cov txheej txheem:

Ntxiv 24LC256 EEPROM rau Arduino Due: 3 Kauj Ruam
Ntxiv 24LC256 EEPROM rau Arduino Due: 3 Kauj Ruam

Video: Ntxiv 24LC256 EEPROM rau Arduino Due: 3 Kauj Ruam

Video: Ntxiv 24LC256 EEPROM rau Arduino Due: 3 Kauj Ruam
Video: Koj yog luag tus los kuv tseem nco. 27.04.2018 2024, Kaum ib hlis
Anonim
Ntxiv 24LC256 EEPROM rau Arduino Due
Ntxiv 24LC256 EEPROM rau Arduino Due

Arduino vim tsis muaj eeprom. Cov lus qhia no ntxiv ib qho thiab tso cai rau koj khaws cov txiaj ntsig hauv cov cim tsis hloov pauv uas yuav muaj sia nyob hloov kho arduino hloov tshiab.

Kauj ruam 1: Breadboarding

Breadboarding
Breadboarding

Muaj qee cov lus qhia zoo tiag tiag ntawm no: https://www.hobbytronics.co.uk/arduino-external-eepromKuv tsuas yog ua raws lawv xwb. tus pin 1 txog 4 thiab tus pin 7 yog hauv av. tus pin 8 txuas nrog 3.3V cov khoom siv ntawm lub rooj tsav xwm. Qhov daj (tus pin 6) thiab dawb (tus pin 5) xov hlau txuas nrog rau i2c SDA (cov ntaub ntawv) thiab SCL (moos) tus pin ntawm lub rooj tsav xwm (suav 21 thiab 20)).

Kauj ruam 2: Sijhawm Sijhawm

Sijhawm Sijhawm
Sijhawm Sijhawm

Nov yog qee qhov ntawm cov lej uas kuv siv hauv kuv daim duab. Ua ntej tshaj plaws, suav nrog Cov ntawv xov tooj Lub taub hau nyob ib qhov twg ze rau saum koj daim duab: / * Siv 24LC256 EEPROM kom txuag chaw * / #suav nrog Tom qab ntawd ntxiv qee qhov haujlwm los nyeem thiab sau bytes los ntawm EEPROM (Kuv tsuas yog saib xyuas tus kheej bytes tab sis muaj nplooj ntawv sau qhov tshwj xeeb hauv nti ib yam nkaus). Nco tseg muaj lub ntsiab lus tseem ceeb ntawm 0x50.. qhov no yog qhov chaw nyob ntawm lub nti ntawm lub tsheb npav i2c (koj tuaj yeem txuas ntau dua ib qho i2c yam ntawm lub tsheb npav i2c thiab xaiv qhov twg koj xav tham nrog los ntawm kev hloov chaw nyob). / * Ob txoj haujlwm no pab peb sau mus rau 24LC256 EEPROM nti */ #define EEPROM_ADDR 0x50 tsis muaj EEPROM_write (unsigned int addr, byte data) {int rdata = data; Wire.beginTransmission (EEPROM_ADDR); Wire.write ((int) (addr >> 8)); // MSB Wire.write ((int) (addr & 0xFF)); // LSB Hlau.write (rdata); Wire.endTransmission (); //Serial.print("EEPROM sau: addr: "); //Serial.print(addr); //Serial.print (""); //Serial.println(data); ncua (5); } byte EEPROM_read (unsigned int addr) {byte cov ntaub ntawv = 0xFF; Wire.beginTransmission (EEPROM_ADDR); Wire.write ((int) (addr >> 8)); // MSB Wire.write ((int) (addr & 0xFF)); // LSB Wire.endTransmission (); Wire.requestFrom (EEPROM_ADDR, 1); yog (Wire.available ()) cov ntaub ntawv = Wire.read (); //Serial.print("EEPROM nyeem: addr: "); //Serial.print(addr); //Serial.print (""); //Serial.println(data); ncua (5); xa cov ntaub ntawv; } Koj tuaj yeem tsis pom qhov Serial.print (…) kab yog tias koj xav pom qee qhov kev debug tso tawm. Hauv kev teeb tsa arduinos () ua haujlwm koj pib lub tsev qiv ntawv xaim thiab tuaj yeem nyeem thawj qhov tseem ceeb. Ntawm no kuv nyeem hauv ob bytes (tus chij thiab max_cc), ob lo lus (lean_min thiab lean_max) thiab cov lus ntawm kab lus sd_max [3]: // nyeem qhov tseem ceeb khaws tseg hauv EEPROM Wire.begin (); chij = EEPROM_read (0); max_cc = EEPROM_read (1); lean_min = lo lus (EEPROM_read (3), EEPROM_read (2)); lean_max = lo lus (EEPROM_read (5), EEPROM_read (4)); rau (int j = 0; j <3; j) {sd_max [j] = lo lus (EEPROM_read (7 j*2), EEPROM_read (6 j*2)); } Nov yog qhov me me ntawm cov cai uas sau lawv rau hauv EEPROM: EEPROM_write (0, tus chij); EEPROM_write (1, max_cc); EEPROM_write (2, lowByte (lean_min)); EEPROM_write (3, highByte (lean_min)); EEPROM_write (4, lowByte (lean_max)); EEPROM_write (5, highByte (lean_max)); rau (int j = 0; j <3; j) {EEPROM_write (6 j*2, lowByte (sd_max [j]))); EEPROM_write (7 j*2, highByte (sd_max [j])); } Hais txog nws tiag.

Kauj Ruam 3: Txuas Nws

Hlau Nws Up
Hlau Nws Up

Hlau nws mus rau qee lub veroboard txhawm rau ntswj rau hauv ib lub thawv thiab cov haujlwm tau ua tiav.

Pom zoo: