Page 1 of 1

I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Mon Nov 10, 2014 11:05 pm
by gicho
Hi,
I am using I2C on STM32F0, but the question is not platform specific.
I am looking for a way to send write command followed by immediate read command, but without STOP in between.
This is needed for the slave chip I am using - ADV7180. At page 78 of the datasheet is shown the READ sequence. It needs first writing to the slave with one byte the gives the register address, then read from the slave (sending the slave address again). Just to note that the WRITE sequence is easily achievable with single call to i2cMasterTransmitTimeout() and it works fine.
My initial idea (for the READ register) was to perform first i2cMasterTransmitTimeout() and then to make i2cMasterReceiveTimeout(). But the chip refuses the second read with NAK. Comparing my logic analyzer trace with those diagrams at page 78 I saw that I have one STOP condition at the end of the i2cMasterTransmitTimeout(). So I think that this is the reason for getting NAK-ed.

Is there a way to do this with the current I2C API?

Re: I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Tue Nov 11, 2014 9:01 am
by Giovanni
The function you mentioned allows for a read phase after transmit without a stop, there is no need for a second call to receive().

Giovanni

Re: I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Tue Nov 11, 2014 9:02 am
by steved
I think you can do the whole thing with a single call to i2cMasterTransmitTimeout() - set up the call to transmit one byte and receive n bytes.

Re: I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Tue Nov 11, 2014 12:45 pm
by gicho
Thank you, I will give it a try. This was my initial implementation but it didn't work. I suspect that I had other problems at the same time (power mode control of the slave chip) so I have to re-test.
Will report back the results.

Re: I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Tue Nov 11, 2014 4:04 pm
by Giovanni
In case of problems please read this too: http://www.chibios.org/dokuwiki/doku.ph ... e_shooting

Giovanni

Re: I2C: i2cMasterTransmitTimeout() without STOP at the end?

Posted: Tue Nov 11, 2014 11:40 pm
by gicho
Sure it worked fine, there was addressing problem in the beginning and it tricked me to believe that default sequence is not suitable for this chip.
Thank you again for being so helpful (on time)!