Operácie

Zbernica i2c

Zo stránky SensorWiki

Verzia z 10:07, 6. december 2012, ktorú vytvoril Chamraz (diskusia | príspevky)

K. Zbernica i2c: EEPROM

Prečítajte obsah predloženej pamäti EEPROM a zobrazte na PC.

Literatúra:


 #define Dev24C02  0xA2      // device address of EEPROM 24C02, see datasheet

 int main(void)
 {
     unsigned char ret;

     i2c_init();                             // initialize I2C library

     // read value from EEPROM address 5 
     i2c_start_wait(Dev24C02+I2C_WRITE);     // set device address and write mode

     i2c_write(0x05);                        // write address = 5
     i2c_rep_start(Dev24C02+I2C_READ);       // set device address and read mode

     ret = i2c_readNak();                    // read one byte from EEPROM
     i2c_stop();

     for(;;);
 }