Joni Bravo
Newbie level 2
877a+sspif
Hi,
Im am trying to make a program what writes to a 24LC512 eerpom(I2C).
I can write to the I2C eeprom but with a delay now i want to use acknowledge polling so its faster.
this is what i have:
When i use a delay instead of the acknowledge polling part it works fine.
The program gets stuck somewhere in the acknowledge polling, so what a i doing wrong??????
Hi,
Im am trying to make a program what writes to a 24LC512 eerpom(I2C).
I can write to the I2C eeprom but with a delay now i want to use acknowledge polling so its faster.
this is what i have:
Code:
void I2C_start(void)
{
SEN = 1;
while(!SSPIF);
SSPIF = 0;
}
void I2C_stop(void)
{
PEN = 1;
while(!SSPIF);
SSPIF = 0;
}
void I2C_send(unsigned char data)
{
SSPBUF = data;
while(!SSPIF);
SSPIF = 0;
}
void I2C_eeprom_write(unsigned char adress_hi,unsigned char adress_lo,unsigned char data)
{
SSPIF = 0;
I2C_start();
I2C_send(control_byte);
I2C_send(adress_hi);
I2C_send(adress_lo);
I2C_send(data);
I2C_stop();
//delay_ms(5); // It works if i use a delay
//acknowledge polling
//Wait while EEPROM is writing
do
{
I2C_start();
I2C_send(control_byte);
}while(ACKSTAT);
I2C_stop();
}
When i use a delay instead of the acknowledge polling part it works fine.
The program gets stuck somewhere in the acknowledge polling, so what a i doing wrong??????