Naumanpak
Member level 2
Experts,
I need to write and read data to slave(24c08).
I am using mikroc PIC I2C library. And the Library Example.
PROBLEM:
Doesnt work.
On debugging I notice that it never sends a byte after start. Perhaps clock not generated??
Kindly suggest me.
thanks
I need to write and read data to slave(24c08).
I am using mikroc PIC I2C library. And the Library Example.
PROBLEM:
Doesnt work.
On debugging I notice that it never sends a byte after start. Perhaps clock not generated??
Kindly suggest me.
thanks
Code:
void main() {
char x;
char *text1 = "Testing";
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
I2C_Init(100000);
I2C_Start();
// Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C
Lcd_Out(2,1, text1); //not displayed
I2C_Wr(2); // Send byte (address of EEPROM location)
I2C_Wr(0xF0); // Send data (data to be written)
I2C_Stop();
Delay_ms(100);
I2C_Start(); // Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C (device address + W)
I2C_Wr(2); // Send byte (data address)
I2C_Repeated_Start(); // Issue I2C signal repeated start
I2C_Wr(0xA3); // Send byte (device address + R)
x=I2C_Rd(0u); // Read the data (NO acknowledge)
I2C_Stop();
Delay_ms(100);
Lcd_chr(4, 1, x);
}