hello
I have try to test the library of software I2C in mikroC using PIC16F877 by writing some byte to a memory 24c512 then read them and put the output on portD which is connected to leds to make sure that the reading values are correct
I make the program to write once and read many but really what I get is that sequential reading didn't occur and I read them only once and seems as if I get hanged after the first reading
I have try to test the library of software I2C in mikroC using PIC16F877 by writing some byte to a memory 24c512 then read them and put the output on portD which is connected to leds to make sure that the reading values are correct
I make the program to write once and read many but really what I get is that sequential reading didn't occur and I read them only once and seems as if I get hanged after the first reading
Code:
void main()
{
int i=0;
trisc=0x00;
trisd=0x00;
Soft_I2C_Config(&portc,0,1);
Soft_I2C_Start();
Soft_I2C_Write(0xA0); //initialization to mem for writing
Soft_I2C_Write(0x00);
Soft_I2C_Write(0x00);
Soft_I2C_Write(0x00);
Soft_I2C_Write(0x01); //00000001
Soft_I2C_Write(0x02); //00000010
Soft_I2C_Write(0x03);
Soft_I2C_Write(0x04);
Soft_I2C_Write(0x05);
Soft_I2C_Write(0x06);
Soft_I2C_Write(0x07);
Soft_I2C_Write(0x08);
Soft_I2C_Write(0x09);
Soft_I2C_Write(0x0a);
Soft_I2C_Stop();
loop:
portd=0x00;
Soft_I2C_Start();
Soft_I2C_Write(0xA0);
Soft_I2C_Write(0x00);
Soft_I2C_Write(0x00);
Soft_I2C_Start();
Soft_I2C_Write(0xA1); //initialization to mem for reading
while(i!=9)
{
portD=Soft_I2C_Read(1);
delay_ms(3000);
i++;
}
portD=Soft_I2C_Read(0);
delay_ms(3000);
Soft_I2C_Stop();
goto loop;
}