cancel
Showing results for 
Search instead for 
Did you mean: 

I2c no stop condition when reading odd number of bytes

lodedeschepper
Associate II
Posted on October 26, 2007 at 03:56

I2c no stop condition when reading odd number of bytes

2 REPLIES 2
lodedeschepper
Associate II
Posted on May 17, 2011 at 09:46

Hi,

I'm using the str912FW44X6 Rev D for my project.

I set up the I2C communication with an external EEPROM witch I use to save some application data.

Writing to the device is never a problem, nor is reading an even number of bytes a problem.

What I noticed on my evaluation board (MCB-STR9) is that when I want to read an odd number of bytes, the processor fails in sending a stop condition on the I2C bus (the processor do send a stop condition after reading a EVEN number of bytes)! After that no I2C communication is possible until I reset the whole communication.

I covered the problem by always reading an even number of bytes, but this 'solution' is not ideal.

Anyone any suggestion?

Best regards,

Louis XIV

lodedeschepper
Associate II
Posted on May 17, 2011 at 09:46

Hi again,

I finally solved my problem.

I started a couple of days ago with the communication with our I2C IO chip. There I needed to read one byte back to read the inputs. After done that, I had the same problem with the EEPROM (see previous post).

I finally found that I didn’t cleared the ‘Ack returned’ bit in the I2C0->CR register. After clearing the bit before reading the last byte of data, a stop condition is generated after the transmission is terminated.

Up to me, it seems pretty clear that I needed to clear the bit at the right moment, but I do not understand why a stop condition is generated after reading even bytes (this was the working solution I’ve implemented to be able to read from the EEPROM)?

But, the most important is that everything works right now as expected.

Best regards,

Louis XIV