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

Calculate RP2040 SDA hold time #4508

Merged
merged 1 commit into from
Mar 29, 2021

Conversation

dhalbert
Copy link
Collaborator

Instead of empirically determining the I2C SDA hold time, calculate the number of clock ticks to get the 300ns required value. See https://www.nxp.com/docs/en/user-guide/UM10204.pdf#page-48, table note [3] for the origin of the 300ns value.

The hardware default is 1, but that is arbitrary, since the length depends on ic_clk. 2 was enough to fix several I2C devices. 5 was need for PA1010D. However, the calculated value is 38 for 300ns. So the other values were quite marginal; this should be a lot safer.

Tested with PA1010D, LIS3DH, BME280, BNO055, and TCS34725.

See adafruit/pico-sdk#3 for a screenshot.

@dhalbert dhalbert requested a review from tannewt March 29, 2021 18:42
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. This won't work for 1mhz though I think. It looks like the SCL fall time for 1mhz is 120ns instead of 300.

@tannewt tannewt merged commit 5804567 into adafruit:main Mar 29, 2021
@dhalbert dhalbert deleted the rp2040-calc-sda-hold-time branch March 29, 2021 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants