Spow
Newbie level 3
Hi,
I'm trying to have an EEPROM and a PIC successfully communicate through the I²C bus.
The accelerometer worked out just fine in I²C (on the same circuit), but I don't seem to be able to read/write data on the EEPROM.
I saw a lot of code on the internet, and mine is pretty standard for that matter (though i coded it myself)
But DEL C2 never lits ! The program does not crash/block though, it simply reads 'FF' when i copy what i read in external eeprom to the internal EEPROM (and visualise it in MPlab).
Is my code wrong ? Or does it come from the hardware ? ( I placed pull-ups on the I²C, though i'm unsure it works)
Thaks for having read.
I'm trying to have an EEPROM and a PIC successfully communicate through the I²C bus.
The accelerometer worked out just fine in I²C (on the same circuit), but I don't seem to be able to read/write data on the EEPROM.
I saw a lot of code on the internet, and mine is pretty standard for that matter (though i coded it myself)
Code:
i2c_start();
i2c_write(0xA0); // SLAVE adress 0 (write)
i2c_write(0x00); // register from l'EEPROM
i2c_write(0x01); // second part of the register adress from the EEPROM (it's a big one :p)
i2c_write(0xAA);
i2c_stop();
i2c_start();
i2c_write(0xA1); // read mode
i2c_write(0x00);
i2c_write(0x01);
i2c_start();
i2c_write(0xA1);
if(i2c_read(0) == 0xAA) output_bit(PIN_C2, 1); //lit a DEL
i2c_stop();
But DEL C2 never lits ! The program does not crash/block though, it simply reads 'FF' when i copy what i read in external eeprom to the internal EEPROM (and visualise it in MPlab).
Is my code wrong ? Or does it come from the hardware ? ( I placed pull-ups on the I²C, though i'm unsure it works)
Thaks for having read.