I used the "Soft I2c" library and it works fine. I have one remark though (mP v 8.0.0.1): the comments added to the example code in the library help could be a little better with respect to the device that is driven (24C02). I would like to propose the following:
Code: Select all
Soft_I2C_Start(); // Issue I2C start signal
Soft_I2C_Write($a2); // Send I2c Write Slave Address (of the 24c02)
ee_adr := 2;
Soft_I2C_Write(ee_adr); // Send EEPROM Word Address (here EEPROM place "2" will be written to)
ee_data := AA;
Soft_I2C_Write(ee_data); // Send data(data that will be written)
Soft_I2C_Stop(); // Issue I2C stop signal
Delay_ms(11); // wait for the maximum write time
Soft_I2C_Start(); // Issue I2C start signal
Soft_I2C_Write($A2); // Send I2c Write Slave Address (of the 24c02)
ee_adr := 2;
Soft_I2C_Write(ee_adr); // Send EEPROM Word Address
Soft_I2C_Start(); // Issue I2Csignal repeated start
Soft_I2C_Write($A3); // Send I2c Read Slave Address (request data from EEPROM)
ee_data := Soft_I2C_Read(0); // Read the data, no ackcnowledge (last byte read)
Soft_I2C_Stop(); // Issue I2C_stop signal
Thanks in advance and keep up the good work!