-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error using non-output pin for SCL in slave mode (IDFGH-269) #2133
Comments
AFAIK, i2c slave must be able to drive SCL active low (clock stretching). |
@loboris under what circumstances does slave mode drive SCL low? I am working on a SlaveMode driver for the Arduino branch, I need this functionality to match the Arduino Slave protocol. Chuck. |
I agree that using a pin without output capability will stop me from possibly doing clock stretching from the ESP32 slave. |
https://learn.sparkfun.com/tutorials/i2c I guess if i2c driver and state machine never uses clk stretching in slave mode it would be ok to use an input only gpio. |
@negativekelvin How do I make the ESP32 clock Stretch in Slave Mode? I understand the i2c protocol, I have found no situations under which I can cause the i2c peripheral to clock stretch. The Arduino i2c protocol, which was based on the capabilities of the AtMega168 automatically started clock stretching as soon as it ack'd the Slave Id, this paused the i2c Master while application code generated the data to be returned. The AtMega168 held SCL low until the driver code released it. During my investigation of the ESP32, there is no delay between the Slave Address Ack and data being set out. If the TX Fifo is empty the ESP32 sends 0xff. If there is any known procedure to cause the i2c peripheral to instigate a SCL stretching operation, I WOULD LOVE to know it! Chuck. |
The clock will be stretched while processing the i2c interrupt or if the interrupts are disabled. |
@loboris I'll read through your changes. Just to verify I am understanding you, you have see the i2c peripheral stretch SCL? I played with it a couple of months ago and was never able to get it to stretch. I'll have to resurrect my test code. During what interrupt are you seeing SCL stretching? I only remember seeing Rx and TX fifo interrupts and Slave_trans_complete during Slave Operations. If the peripheral was in slave Mode, TX_Fifo_empty would trigger until the fifo level meet the thrld. This resulted in stale data. I am hoping to fill the fifo when Slave_id is Ack'd. I'll look through your code and try to see where the stretching happens, I am using the Arduino base not IDF so it is a little different. Chuck. |
A standard I2C Slaver requires the ability to output SCL, as well as configuring SCL as open-drain output in Master mode. If you don't need this capability, you can modify the I2C code. But it's impractical to make changes on the master branch. |
@xiongyumail I'm just saying:
A regression
But then it checks that SCL is either a valid OUTPUT GPIO or just a valid GPIO if we're requesting SLAVE mode.
IMO, this proves that the original intention was to allow (restricted, maybe) SCL operation on an input-only pin. Commit b1fa1ba breaks that scenario: the Confusing Trivial fix
instead of
The glitches can't appear simply because an input pin can not pull that line down. |
…ssif#2133) * WiFiClientSecure: add support for PSK (pre-shared key) ciphers * add example for WiFiClientSecure PSK * WiFiClientSecure: added README
Environment
Problem Description
Commit 1ad68de (fixing #393) produces an error on the console when using a non-output pin in slave mode for SCL.
It seems that the message may not be critical, but it's really confusing.
Expected Behavior
Able to use pin 34 for SCL in slave mode.
Actual Behavior
The error stated in the description appears on the log.
Steps to repropduce
Modify the i2c sample to use pin 34 on the slave for SCL.
Suggested fix
Only call
gpio_set_level
if configuring MASTER mode, but not in SLAVE.The text was updated successfully, but these errors were encountered: