Hi Ian,
Thank you again.
And thank you very much for sharing your code.
I modified the reading section in code according to your advice, please see code section below.
However, what happened was that:
1. I still didn't manage to read a value from the Slave (GLCD)
2. This modification caused that I couldn't communicate from that point with the GLCD anymore, and couldn't continue writing to it
Could you add your entire section where you write and read to and from the slave? (what is your slave btw?)
I'd like to see how you perform the reading.
For example, whether you use "Restart", and whether you send the Slave Address with the R/W bit set before setting the RCEN bit.
And whether you wait for an ACK from the Slave before you set the RCEN bit.
* This is what the GLCD datasheet says on reading from the GLCD:
I2C interface Read Data command includes two transactions:
First transaction sends a command to read the data from slave device (data request);
Second transaction read the data from slave device.
Thank you very much!
//READ y Cursor Position from Slave
StartI2C();
putcI2C(GLCD_WRITE); //0x8C
putcI2C(0xFE);
putcI2C(0x07);
RestartI2C();
putcI2C(GLCD_READ); //0x8D
IdleI2C();
SSPCON2bits.RCEN=1;
while(PIR1bits.SSPIF==0);
PIR1bits.SSPIF=0;
unsigned char i2cReadData;
i2cReadData = SSPBUF;
StopI2C();