2024-11-17 12:34 PM
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:
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:
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.
2024-11-23 12:06 PM
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..
2024-11-23 02:23 PM - edited 2024-11-23 02:24 PM
> 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.