I am using C18 compiler and I learned that acknowledge polling feature will greatly help in reducing the write time that is to remove the fixed delay in traditional methods. Well I am using EEPROM 24LC256 and there is a feature for acknowledge polling in it.
I have written a code for Acknowledge Polling.
long eewrite_p( int address,int msg)
{
int my_response;
int i;
i2c_init();
//if(!i2c_initialised) return '\0';
StartI2C(); //Send the Start Bit
Nop();
IdleI2C(); //Wait to complete
Nop();
WriteI2C( 0xA0 );
Nop();
IdleI2C();
//Wait to complete
WriteI2C( address>>8);
Nop();
IdleI2C();
WriteI2C(address&0xFF);
Nop();
IdleI2C();
my_response = WriteI2C(msg);
Nop();
AckI2C();
IdleI2C();
StopI2C(); //Send the Stop condition
Nop();
IdleI2C(); //Wait to complete
}
Well, this is an old code w/o acknowledge polling. I've read about acknowledge polling for every Control Byte/Data/Address Byte is necessary. Correct me if I am wrong. Do we need to do an acknowledge polling for every Byte written in to the chip?
Another doubt I have is if we check for acknowledgement and if it is not received then the Datasheet/App notes says wait till Acknowledge is received. Else the code is polled till Acknowledge is received.
Well, previously I tried writing EE device address, one function after another, w/o any delay in between them and I trust it must not have been written well. How can I modify the current code to make use of Acknowledge polling?