ST24C08 EEPROM and Arduino

preview_player
Показать описание
ST24C08 EEPROM and Arduino

Join this channel:

Thanks for watching.
Рекомендации по теме
Комментарии
Автор

code:
#include <Wire.h> /* Arduino native library handles I2C things */

void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
/* ST24C08 8192 bit eeprom, 1024 bytes in 4 blocks of 256 */
Serial.print("address . ");
Serial.println("data");
/* read the eeprom data one byte each time */
for(uint16_t i = 0; i < 1024; i++) {
byte data = readExtEEPROM(i);
Serial.print(i); /* print address */
Serial.print(" . ");
Serial.println(data); /* print data */
}
}

void loop() {
}

/* ST24C08 I2C EEPROM read */
byte readExtEEPROM(uint16_t address)
{ /* block address will be 0x50 (0-255), 0x51 (256-511), */
/* 0x52 (512-767), and 0x53 (768-1023): */
int blkAddrs = 0x50 + (address >> 8);
/* I2C address */
Wire.write(address & 0xFF); /* memory address */
Wire.endTransmission();
Wire.requestFrom(blkAddrs, 1); /* ask for 1 byte */
if(Wire.available()) return Wire.read(); /* read its value */
}

/* I2C EEPROM write */
void writeExtEEPROM(uint16_t address, byte data)
{
int blkAddrs = 0x50 + (address >> 8);
/* I2C address */
Wire.write(address & 0xFF); /* memory address */
Wire.write(data); /* write data to eeprom */
Wire.endTransmission();
delay(12);
}

unrelatedactivities
Автор

Great Song.. what's the name of it?

daVbOz