# Acknowledge polling in EEPROM

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

Nop();
IdleI2C();

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?

If a typical EEPROM acknowledges the first byte following a start condition, there is no defined sequence of events via which it would fail to acknowledge any other byte which is sent in accordance with specifications. Testing for acknowledgment after subsequent bytes might help code detect that something went wrong if a glitch occurs and knocks things "out of sync", but may not really help anything unless the code can do something useful in response.

In my own code, my normal approach is to bit-bang I2C with routines:

bit I2C_StartRead(unsigned char address);