cancel
Showing results for 
Search instead for 
Did you mean: 

I2C - Delay between address byte and first data byte when reading

GoEk
Associate III

Hi,

is there anyway to insert a delay between the start generation address byte transmission and the first data byte reception from the slave device? I have tried reading 0 bytes from the slave to prevent the reading of the first byte but that sets the Transmission Complete bit which can only be cleared by another Start condition, which puts me back on square one.

BR

Goran

8 REPLIES 8
Pavel A.
Evangelist III

Yes, this is called "clock stretching". Read on this in I2C documentation.

 

I may have been unclear, what I mean is to, as a master doing a read of a slave device, on the MCU side put in a delay between the start/address byte and the first data byte read. My slave device does not have clock stretching but  instead requires "a 100us delay between all bytes (including address byte) that is read/written over the bus". If it is unhappy it simply NACKs if it is too busy, anywhere in the ongoing transmission.

Karl Yamashita
Lead III

What slave device is this? That is a very unusual requirement.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
Pavel A.
Evangelist III

This is unusual, but just simply make the delay. The master drives the clock. Just do not drive it for the needed time. If no existing library function does this, just write your own.

 

You could always bit-bang the bus, or just have some timed callback after each byte, ie gets the IRQ,and sets up a deferred processing task.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

TI MCT8316A. They realize this is a fault and "it will be fixed in the next chip revision" which doesn't help me since it is already used in hundreds of products.

Tried that, I all works except for reads where I have no way of inserting the delay between the address and first data byte.

Got it all working except there seems to be no way to get the I2C port, during a read, to halt after the address byte. I can read 0 bytes and the I2C terminates with the Transfer Complete ISR bit set. Unfortunately, the only way to clear that bit is by issuaing a Start or a Stop condition which is not what I want.

 

I also tried using the Reload functionality which instead sets the TCR bit which CAN be cleared but if I set the RELOAD bit during a 0 byte read, the TC flag still gets set.