Skip to main content
Associate
November 17, 2024
Question

Addind Delay between I2C Master to Slave Address Send and Data for Read Operation

  • November 17, 2024
  • 3 replies
  • 1594 views

Hello,

I am interfacing with a sensor via I2C, with my STM32G0 MCU as the master. The sensor (Panasonic SN-GCJA5 air particulate sensor) requires a 500us delay between the I2C address read byte, and the data being read from that register:

 

jesseCST_1-1731875041718.png

This is definitely an uncommon requirement, but here we are. To be clear, this is not clock stretching. It appears the device expects a hard coded delay for some kind of internal processes to complete before data is available. I have tried without the delay, and sure enough no data from the sensor is presented. I have found other forum posts that have similar questions, with no answer yet:

https://community.st.com/t5/stm32-mcus-products/i2c-delay-between-address-byte-and-first-data-byte-when-reading/m-p/743724#M266420

https://community.st.com/t5/stm32-mcus-products/i-want-to-make-a-delay-between-the-slave-address-and-the-data-in/td-p/159249

I have gone below the I2C's HAL to see if there are register level manipulations that can make this possible, but I don't see a way to do it. Anything below byte level reads and writes seems to be abstracted in hardware. However I am not an STM32 I2C expert. Does anyone know of a clean way of doing this?

Generating a bit-bang I2C software interface is not an option for this design. 

Thank you.

3 replies

Senior III
November 23, 2024

you may have to use LL function to wait for LL_I2C_IsActiveFlag_BTF
Function name
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BTF (I2C_TypeDef * I2Cx)
Function description
Indicate the status of Byte Transfer Finished flag

 

I guess you can use the HAL_I2C function with a longer timer for timeout , the HAL function waits that much time before return with error code.

 

I2 C Status register 1 (I2C_SR1).BTF flag may be a solution.. 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
Super User
November 23, 2024

To be clear, this is not clock stretching.

Have you checked SCL with a scope? From the picture, it looks just like the device may stretch SCL, before ACK for slave address.

Visitor II
May 6, 2025

Were you able to start the correct communication? If so, could I ask for a function to support the SN-GCJA5 sensor for stm32g0, I would be very grateful.