I2C: i2cMasterTransmitTimeout() without STOP at the end?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
gicho
Posts: 16
Joined: Sun Aug 24, 2014 8:44 am

I2C: i2cMasterTransmitTimeout() without STOP at the end?

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post 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
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

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

Post 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.
gicho
Posts: 16
Joined: Sun Aug 24, 2014 8:44 am

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

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post by Giovanni »

In case of problems please read this too: http://www.chibios.org/dokuwiki/doku.ph ... e_shooting

Giovanni
gicho
Posts: 16
Joined: Sun Aug 24, 2014 8:44 am

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

Post 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)!
Post Reply