Skip to content
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

ESP32C3 Wire I2C - SCL hang and 1 second timeout on transfer performed after NAK #8454

Closed
1 task done
l0ud opened this issue Jul 24, 2023 · 4 comments
Closed
1 task done
Assignees

Comments

@l0ud
Copy link

l0ud commented Jul 24, 2023

Board

WeAct ESP32-C3FH4

Device Description

WeAct ESP32-C3FH4 with only BMI160 sensor wired in. WeAct board is very basic containing just ESP32C3FH4 chip, voltage regulator USB port and some buttons.

Hardware Configuration

BMI160 IMU wired using i2c to ESP32C3 4 and 5 pin.

Version

v2.0.6

IDE Name

PlatformIO

Operating System

Manjaro Linux

Flash frequency

Default

PSRAM enabled

no

Upload speed

Default

Description

Scenario is the following:

  • I'm writing 0 bytes (only address) to device 0x68 to check if it's available. It responds with ACK and I get success status, all good here.
  • I'm writing address to device 0x69 to check if it's available. It's not, I have NACK status, all good.
  • I'm writing again 0 bytes to device 0x68 expecting it to succeed. However it fails with timeout.

On screenshot I'm showing overview of first 3 transfers on i2c bus:

  • successful write to 0x68 (only address written, then ACK). Transfer reported as successful.
  • failed write to 0x69 (no ACK after address, as expected). This transfer returns failure, as expected.
  • successful write to 0x68 (with ACK) with SCL line stuck low for one second! This transfer returns timeout error.
    image
    BMI160 doesn't support clock stretching, so SCL stuck low is probably ESP fault.

Zoom in to last transfer:
image
And recovery after one second (I'm starting another transfer to 0x69):
image

Sketch

byte status;
while(1) {
Wire.beginTransmission(0x68);
status = Wire.endTransmission();
Serial.printf("Address 0x68 status %d\n", status);
Wire.beginTransmission(0x69);
status = Wire.endTransmission();
Serial.printf("Address 0x69 status %d\n", status);
}

Debug Message

Address 0x68 status 0 [OK]
Address 0x69 status 2 [NACK, OK]
Address 0x68 status 5 [timeout, not ok, should be 0]
Address 0x69 status 2 [NACK, OK]
...

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@SuGlider
Copy link
Collaborator

SuGlider commented Aug 4, 2023

@me-no-dev PTAL, thanks!

@l0ud
Copy link
Author

l0ud commented Aug 23, 2023

I looked around and now I'm wondering, is that not related to espressif/esp-idf#9777 ?
I looked at files I have locally and it seems like my sources doesn't have that patch included.

@me-no-dev
Copy link
Member

2.0.6 is old. latest version have this fix already included.

@VojtechBartoska VojtechBartoska added Status: Solved and removed Status: Awaiting triage Issue is waiting for triage labels Aug 23, 2023
@VojtechBartoska
Copy link
Contributor

Closing as solved, thanks @me-no-dev for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants