ESP32-S3 I2C clock polarity

eeprom_0
Posts: 1
Joined: Wed Jul 26, 2023 10:26 pm

ESP32-S3 I2C clock polarity

Postby eeprom_0 » Wed Jul 26, 2023 10:30 pm

Hi,

I am trying to interface my esp32-s3 with an I2C device that samples data on the falling edge of the clock. To my disappointment, There doesn't seem to be a clock polarity option in the I2C configuration.

Is there a way to modify the driver so that the polarity of the clock is inverted?

Thank you.

ESP_Sprite
Posts: 9053
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 I2C clock polarity

Postby ESP_Sprite » Thu Jul 27, 2023 1:37 am

Technically, that is not an I2C device as it violates the I2C specifications (which say that the sampling should happen when SCL is high), and that's why the I2C driver doesn't have an option to generate a signal like this. (We have a way to invert GPIO outputs wholesale, but in this case that wouldn't work as it would generate invalid start and stop conditions.)

With that being said, the I2C driver does allow for a SDA hold time; if this is nonzero it'll hold the SDA signal for a while after SCL goes low. Setting this to some sane value might allow your weird device to grab the SDA value before it changes. Use i2c_set_data_timing() to set it.

Who is online

Users browsing this forum: Bing [Bot] and 194 guests