arduino / arduino/ArduinoCore-megaavr

Wire.setClock() keeps SCL low with 800kHz

Open
#107 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
111
Forks
65
PR merge metrics
No merged PRs in 30d

Description

The default 100 kHz works, and the `Wire.setClock(100000L)` works.
If the clock is set to 800 kHz or above, then the SCL signal stays low because of a missing stop condition.
The I2C speed for normal signals should be from 100kHz to 400kHz, but someone might try 800kHz.

Tested with Arduino IDE 1.8.15 and Nano Every board. Nothing is connected to the I2C bus.
Test sketch:
```
#include

void setup()
{
Wire.begin();
Wire.setClock( 100000L);
}

void loop()
{
Wire.beginTransmission( 0x2B);
Wire.endTransmission();

delay( 100);
}
```

Result with a sample rate of 24 MHz with LHT00SU1 and PulseView/sigrok).
The measured frequency of SCL varies a few percentage. It is 99 kHz with no pullup resistors here:
![100](https://user-images.githubusercontent.com/12096541/128616588-dae9fced-8424-4ee5-8658-fb70e6b0d32b.png)

With `Wire.setClock(400000L);` the measured frequency of SCL is 303 kHz with no pullup resistors:
![400](https://user-images.githubusercontent.com/12096541/128616592-54e04658-80ad-4f42-97b6-d3935d89aba7.png)

With `Wire.setClock(800000L);` the SCL signal stays low. There is no stop condition. The SCL raises before the next start condition. The measured frequency of SCL is 525 kHz with no pullup resistors.
![800wide](https://user-images.githubusercontent.com/12096541/128616678-c1b369bf-8690-49af-99a6-a476bc188a4b.png)

[Update] I have edited this Issue because I learned that not the clock speed of SCL is set, but that the resulting clock speed is relative to the rise time.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Wire.setClock() and endTransmission() entry points in the ArduinoCore-megaavr implementation, then compare the 100 kHz, 400 kHz, and 800 kHz behavior described in the issue. Use the provided Nano Every sketch and logic-analyzer measurements to investigate the missing stop condition; done means SCL produces a valid stop condition at 800 kHz or the supported limit is clearly enforced.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.