Re: Pic16f887 i2c eeprom
Things are becoming even more complicated. After tried every thing I didn't succeed but then I used software I2C library routines and it worked but with abnormal result.
The example code given in MikroC was for 1 byte address EEPROM but in REAL PIC SIMULATOR the EEPROM 24C64 has 1 word address. see the picture below.
so I edited the code like this
-------------------------------------------------------------------------------------------------------------------------
// Software I2C connections
sbit Soft_I2C_Scl at RC3_bit;
sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections
void main()
{
delay_ms(500);
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xA0); // control byte
Soft_I2C_Write(0x00); // address high byte
Soft_I2C_Write(0x20); // address low byte
Soft_I2C_Stop();
}
-------------------------------------------------------------------------------------------------------------------------
note that I didn't write EEPROM data because the code is working fine wothout data and is pointing to memory location 0020 see the picture below
but whenever I insert the data the result becomes abnormal
-------------------------------------------------------------------------------------------------------------------------
// Software I2C connections
sbit Soft_I2C_Scl at RC3_bit;
sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections
void main()
{
delay_ms(500);
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xA0); // control byte
Soft_I2C_Write(0x00); // address high byte
Soft_I2C_Write(0x20); // address low byte
Soft_I2C_Write(0xAA); // data byte
Soft_I2C_Stop();
}
-------------------------------------------------------------------------------------------------------------------------
see the result below
I don't know what to do I tried every thing like convert address to 1 byte but nothing.
I prefer you please check code on REAL PIC SIMULATOR.