Mensaje editado por: Maria Mor
Original Attachment has been moved to: i2c.rar
Hi Maria,
I can't completely see a path through your code but presuming your S08 is the master and the LCD is a slave, I would have a look at the IICC MST bit. I'm not sure if you have it set when you start a transmission?
I'm also not sure that the two lines below the /* Reset 24c02 */ comment are necessary.
Thanks,
Ian
Hi Ian.
Effectively the DEMO9S08QG8 is the master and the slave plantalla lcd.
Regarding the MST bit, I think it's okay, it has to be 0 while not want to send a stop signal and when you want to stop sending data is the i2c_stop_condition () function to send the stop sign.
I do not understand what you mean with the "two lines below the / * Reset 24c02 * / comment".
I appreciate your comment and you've taken the time to look at the code.
Hi Maria,
Here is some code I used recently to read a status byte from an I2C slave. It looks quite similar to your code but I have to admit I am no expert on I2C ;-)
IICC_TXAK = 0;
IICC |= 0x30; // Generate START
IICD = 0xEE; // write to slave device
while (!IICS_IICIF); // wait until flag is set
IICS_IICIF=1; // Clear the int flag
while(IICS_RXAK); // Check for RXAK
IICD = 0xD0; // write command
while (!IICS_IICIF); // wait until flag is set
IICS_IICIF=1; // Clear the int flag
while(IICS_RXAK); // Check for RXAK
IICC_RSTA = 1; // setup repeated start
IICD = 0xEE|1; // (slave_address)|(RW = 1), read from slave
while (!IICS_IICIF); // wait until flag is set
IICS_IICIF=1; // Clear the int flag
while(IICS_RXAK); // Check for RXAK
IICC_TX = 0; // Setup to receive
IICC_TXAK = 1; // Acknowledge disable
RD_data = IICD; // Dummy read
while (!IICS_IICIF); // Wait until IBIF flag is set
IICS_IICIF=1; // Clear the flag
IICC_MST = 0; // Generate STOP
RD_data = IICD; // Read data
The MST bit is set on the "// Generate start" line but I can't fully see how it is configured in your code taken on board the comments you made in your email.
What I meant by the comment is that I don't think you need the I2C start and stop function calls under the /* Reset 24c02 */ comment, unless of course a 24c02 does require these calls :-) Usually slaves by default are listening for I2C bus activity etc.
Thanks,
Ian