electroRF
Member
Hi,
I have a problem - my PIC18F fails reading bytes from I2C GLCD Slave (GLCD-FLEXEL).
I found an Arduino code, which uses the following function to read 1 byte from the GLCD.
I think that the reason for which I don't manage to read from the GLCD, using C Code that runs on my PIC, is that I don't know how to translate the Wire.requestFrom to C Code.
How do you do that?
I don't have HW problem as I do manage to write data to the LCD.
Reading is the problem.
Thanks!
unsigned int GLCDI2C::getColor(void){
unsigned int data = 0;
unsigned char number = 1;
Wire.beginTransmission(g_i2caddress);
Wire.write(GLCDI2C_COMMAND);
Wire.write(GLCDI2C_GET_COLOR);
Wire.endTransmission();
//delay(GLCDI2C_CMDDELAY);
// Connect to device and request byte
Wire.beginTransmission(g_i2caddress);
Wire.requestFrom(g_i2caddress, number);
if (Wire.available()) {
data = Wire.read();
}
return data;
}
I have a problem - my PIC18F fails reading bytes from I2C GLCD Slave (GLCD-FLEXEL).
I found an Arduino code, which uses the following function to read 1 byte from the GLCD.
I think that the reason for which I don't manage to read from the GLCD, using C Code that runs on my PIC, is that I don't know how to translate the Wire.requestFrom to C Code.
How do you do that?
I don't have HW problem as I do manage to write data to the LCD.
Reading is the problem.
Thanks!
unsigned int GLCDI2C::getColor(void){
unsigned int data = 0;
unsigned char number = 1;
Wire.beginTransmission(g_i2caddress);
Wire.write(GLCDI2C_COMMAND);
Wire.write(GLCDI2C_GET_COLOR);
Wire.endTransmission();
//delay(GLCDI2C_CMDDELAY);
// Connect to device and request byte
Wire.beginTransmission(g_i2caddress);
Wire.requestFrom(g_i2caddress, number);
if (Wire.available()) {
data = Wire.read();
}
return data;
}