We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello All,
I am finding it really hard to perform write and read operations on the EEPROM connected to the MCU by two wires using the I2C Protocol.
I've read the data sheets, written the code exactly matching the datasheet info, but it was of no avail.
Please help me out.
My code looks something like this
void Write_Start(void) { E2P_SDA = 1; E2P_SCL = 1; delay_i2c(); E2P_SDA = 0; delay_i2c(); E2P_SCL = 0; delay_i2c(); } void Write_to_E2P(void) { unsigned char DEV_SEL_CODE = 0x0A0; unsigned char ADDR_MSB = 0x50; unsigned char ADDR_LSB = 0x05; unsigned char i; Write_Start(); for(i=7;i>=0;i--) { E2P_SDA = DEV_SEL_CODE^i; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); } E2P_SDA = 1; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); delay_i2c(); E2P_SCL = 0; delay_i2c(); if(E2P_SDA == 0) LED1=1; for(i=7;i>=0;i--) { E2P_SDA = ADDR_MSB^i; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); } E2P_SDA = 1; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); delay_i2c(); E2P_SCL = 0; delay_i2c(); if(E2P_SDA == 0) LED2=1; for(i=7;i>=0;i--) { E2P_SDA = ADDR_LSB^i; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); } E2P_SDA = 1; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); delay_i2c(); E2P_SCL = 0; delay_i2c(); if(E2P_SDA == 0) LED3=1; for(i=7;i>=0;i--) { E2P_SDA = current_channel^i; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); } E2P_SDA = 1; E2P_SCL = 0; delay_i2c(); E2P_SCL = 1; delay_i2c(); delay_i2c(); E2P_SCL = 0; delay_i2c(); if(E2P_SDA == 0) LED4=1; }
(Video of one of MY babies...)
Does your mum know you use Google after bedtime, Vince?