-
-
Notifications
You must be signed in to change notification settings - Fork 87
Wire clock is slow for some 3.3V devices. #69
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
@greiman |
I am not sure what the fix is. 5V devices run at slightly over 400kHz, 3.3V have some rate less than 400kHz. It appears to vary a lot depending on the device. I have not experimented with mixes of devices. I2C has clock stretching. Maybe at close to 3V the Renesas controller thinks the device wants to slow down. From the standard:
The other problem with Wire is that you can't select a rates other than 100kHz, 400kHz, 1MHz. setClock just ignores other rates. Seems like Renesas should help with this. |
Thanks for your post. I decided to play with pullup resistor size and pullup voltage. Case with bigger resistor. Rate goes from above 325 kHz to 285 kHz. Case with even larger pullup resistor (larger resistor means less pullup). Clock becomes erratic. The device still works! At about 3.0 V pullup voltage, the clock stops for any pullup resistor size. |
Just out of interest.. did you connect to the Qwiic connector (Wire1) or to the A4/A5, D18/D19 (Wire). The reason for asking is that the Qwiic connector (Wire1) is 3V3. The SCL/SDA signals get a level change from 3V3 to 5V and are then connected to the Renesas processor. |
I did not use Wire1 on the Qwiic connector. I think there is a good chance a level shifter would help. I was looking at the I2C standard and was realizing we have been lucky with the forgiving nature of the Uno R3 and other I2C controllers. If VDD is the bus voltage, that is the pullup voltage then: VL, Max LOW-level input voltage. is 0.3*VDD, or 1.5 V if VDD = 5V. VH, Min HIGH-level input voltage is 0.7* VDD or 3.5 V if VDD = 5V. So for a 3.3V, the bus max voltage is less than the 3.5 V specified by the standard for min HIGH voltage. I have made devices work by adding pullups to 5V. I suspect most devices are 5V tolerant. Since:
The standard says things like this:
I have Qwiic connectors/cables and devices but I wish someone else would pursue this issue. |
@greiman Right now I am testing with a Lidar Lite V3 (5v), SSD1306 and a 3.3v MPU9250. This is all running the Wire from a Minima board. If hook up a LA and look at each device in the traces: 0x62 (Lidar Lite V3) - same thing, alternates between 400khz at 52% and 384khz at 53.8% duty. 0x3c (SSD1306) - same thing, alternates between 400khz at 52% and 384khz at 53.8% duty. Individually I am seeing what you saw. The only PRs that I have incorporated were micros, and the setclock fixes. |
I did. Works like a charm with a SDD1306 display on Wire1. I looked at many captures and it almost always runs at 399.04 kHz. A tiny variation but that is within sampling error for the logic analyzer. The voltage on the Qwicc connector is 3.29 V. The display is powered by this voltage. |
I agree. Too bad the R4 Minima has only the 5V Wire. The Uno R3 works well with 3V3 I2c since at the time the AVR I2C controller was designed there were many legacy devices. Here is a statement from the I2C standard:
So now the minimum voltage for HIGH on 5V devices is 70% of 5V or 3.5V. |
@greiman = been testing a bit more today with a I2C test board that we used with the Teensy, same as previously but with more added:
Note an SSD1306 is on Wire In that configuration the test sketch worked fine no issues but the minute I enable the BNO055 it indicated it could not be found. I enabled the 055 and disabled the 080 it worked. Earlier in the morning was testing with a bno080 + a TPM102 board on Wire + a 9250 on Wire1 and after a few seconds the sketch lost the all devices on Wire but wire1 kept working. Have to do some more testing but it might be an issue with these BNO type devices. Just thought you would like to know. |
Did some more testing with the BNO055 and TMP102 devices on Wire/Wire1. Confirmed they fail on both ports. Tested on a M0 board that I have and no issue. Did verify that wirescanner picked them up and they did. |
don't know about the TMP102, but the BNO0555 is using clock stretching and caused many issues with the RPI. There are many articles on internet.. Could that be a reason ? |
The BNO080 also suffers with clock stretch.. e.g. adafruit/Adafruit_CircuitPython_BNO08x#7 |
@paulvha - Actually I think I got it resolved. Out of curiosity I looked at another library for the BNO55 for the arduino: https://github.com/arduino-libraries/BNO055, and saw this//Pin assignments as tested on the Arduino Due.
Never hooked up PS0 and PS1 to gnd before so gave it a try and it worked. So now have data streaming from both the 080 on Wire1 and 055 on Wire. Also works with both devices on Wire :) Wonder if there is some delta in the libraries for the 2 chips since both have PS0/PS1 lines |
[QUOTE] The BNO080 also suffers with clock stretch.. e.g. adafruit/Adafruit_CircuitPython_BNO08x#7 [/QUOTE] Agree but I am using the Sparkfun library for the BNO080 and do not seem to have any issues with it connecting and runnin Now that I have them running should let them keep running for more than a couple of minutes to see if they fail |
I checked the RA4M1 datasheet for I2C Vih and it is the the standard value: Then I realized I didn't know what Vcc is in my tests using USB. I measured the V5 pin which is connected to Vcc and it is 4.678? V. I am using a 5.5 digit meter and the low digit flickers I then powered the board with a 9V Power adapter. The 5V pin is now 4.9892 with the 5 digit meter. This could make a difference in performance. 70 % of 4.678 = 3.27V. Might mainly work for 3V3 devices. 70% of 4.9892 = 3.49V. Might be less reliable. I don't feel like doing tests. I use mostly 3V3 devices so I am losing interest in Uno R4. Time for me to give up 5V boards. Edit: with ΔVt being Vcc x 0.05 or about 0.25 V it's not worth trying to use 3V3 on Wire. |
agree 100%. Does not make sense to try/challenge "on the margin". In the case of building a solid solution, it is better to stay within the max. of 80% of the boundaries, if not better.. |
Update RTC Library (Unix function)
Update RTC Library (Unix function) Former-commit-id: a7c9a2f
The RA4M1 I2C controller runs slower than the selected clock rate for some 3.3V devices. These devices run at the full rate on Uno R3.
I have had no problems with 5V devices. All 5V devices I have tried run at 400kHz.
I looked for any issues for RA4M1 on the Renesas site. It seems the controller is very fussy for 3.3V devices. Devices fail if powered by slightly less than 3.3V and Renesas states:
Here is an example with a SSD1306 128 x 64 OLED display which has 4.7 K pullups to 3.3V.
On a R4 Minima I get 329kHz for 400kHz requested clock. I get 95kHz for 100 kHz requested clock.
I added an analog trace for SCL.
For the same program and device on Uno R3 I get exactly 400 kHz.:
Any Ideas what is causing 3.3V devices to run a bit slower on R4?
I have not tried more than one I2C device at a time on R4.
Edit: Are internal pullups enabled on R4?
The text was updated successfully, but these errors were encountered: