-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32-C6 Actual I2C frequency not change, always 100KHz #11241
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
Comments
I also test the code on ESP32 S3, and it is the same issue. It's always 100KHz. |
But with Wire Master example, its frequency could be changed. It's strange. |
Please verify which version of arduino-esp32 you are using, as this driver is currently going through changes. |
I use esp-arduino 3.2. |
Have you tried Wire.setClock(); ? This is working fine for me. |
Just looking at the code for ESP32-classic and ESP32-C6. ESP32-classic: The code for ESP32-classic is very basic and easy to understand. Take for example this line: uint32_t clkm_div = source_clk / (bus_freq * 1024) + 1; Since nearly all I2C clock frequencies are >= 100 kHz, this This same line is present for:
Only the ESP32-classic and the ESP32-S2 seem to do it differently. To draw some conclusions... Edit: uint32_t clkm_div = source_clk / (bus_freq * 1024) + 1;
uint32_t sclk_freq = source_clk / clkm_div;
uint32_t half_cycle = sclk_freq / bus_freq / 2; |
@TD-er , you run my test code above? If I run normal code of I2C, such as writing, reading then I could change I2C freq at any value within its possible range. Only scan code above is fixed at 100KHz. |
I've already tried. But it is still fixed at 100KHz for my scan code above. For other readings, writings, it could be changed to any frequency I set. |
Nope, I ran my own project code. I'll have a look at your code to see if I see something obviously different compared to how I initialize Wire |
Hmm scan code running at 100 kHz is some really good feature, so you can be sure to also find those older devices not capable of running at > 100 kHz. |
Just checked my code... Wire.setPins(sda, scl);
Wire.begin();
Wire.setClock(clockFreq); This differs from what you're doing, so maybe you can try it using this sequence? |
Here is the answer: https://github.com/espressif/esp-idf/blob/master/components/esp_driver_i2c/i2c_master.c#L1295-L1300 The new IDF driver always does scan at 100kHz. Closing the issue :) |
@me-no-dev thank you for your clarification. |
Board
ESP32-C6-DevKitC-1
Device Description
ESP32-C6-DevKitC-1
Hardware Configuration
GPIO 23 for SDA, 22 for SCL.
Version
latest stable Release (if not listed below)
IDE Name
Arduino IDE
Operating System
Ubuntu 22
Flash frequency
80Mhz
PSRAM enabled
no
Upload speed
512000
Description
Using Wire Scan example. I set frequency 10Khz but actual waveform is still 100Khz. Change to 400Khz, it still keeps 100Khz. Using Wire.getClock() shows the same freq as setting.
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: