-
Notifications
You must be signed in to change notification settings - Fork 22
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
"Timed out waiting for transfer to finish." #16
Comments
Hi zirafa, The timeout is set by the If you're going to do that, please make sure you get enough measurements to be sure that there's a real difference. It's very easy with intermittent faults to convince yourself that something makes a difference when it's just a quirk of random noise. I'd suggest a minimum of 20 data points for each condition. I can think of 2 possible reasons for the problem. (There may well be more!)
The ISR problem is easy to avoid. ISR's are callback functions that sit outside Electrical problems are always an issue with I2C because the protocol doesn't have any built in error correction or retry mechanism. When something goes wrong you either get an incorrect data value or the transaction fails. In the worst case scenario the I2C bus can lock up and every following transfer fails as well. It's difficult to eliminate electrical problems but you may be able to make them very rare. (I have a system which generates less than 1 error per million transfers.)
Does your system continue to work correctly after you've seen the error or do you have to reset it? i.e. is this issue just a nuisance or a major problem for you? cheers, |
Thank you for the detailed response! I will certainly investigate the wiring issues (quite messy) and ISR transfers. The weird thing is the problem does not occur when using the default Wire.h library. Maybe Teensy4_I2C is revealing some underlying instability in my setup that doesn't occur with Wire.h, but I'm not sure -- my expectation is that if a system is stable using Wire.h it would also be stable when using Teensy_I2C. As for the severity of the problem, it is major. The system starts fine, but after receiving some input it becomes overloaded (basically all sensors suddenly turn on for a few milliseconds, causing a noise glitch) and then quickly settles down and continues to run (until it receives more input). If I keep pushing it with continuous input, sometimes the system will lockup and the Teensy will crash entirely, requiring a hard reset. |
I agree that if the system is stable with the default Wire library then it should be stable with Teensy4_I2C as well. This strongly suggests that there's a software bug somewhere rather than a hardware problem. You definitely shouldn't be able to crash the Teensy! I've got a few questions.
Please can you send me the simplest possible example that illustrates the problem. I'll see if I can reproduce it. |
Hi, It's quite possible that you're having the same problem. I've made some experimental improvements on the stuck_bus branch. Please give this a try and see if it improves the situation at all. I know it doesn't solve all the problems with the master but it may help. There's a well known I2C issue called a "stuck bus" which can happen when a slave is waiting for the master to do something but the master has stopped listening. The Wire library I2C driver has a method called force_clock which can sometimes reset the slave automatically. My driver doesn't do that so this may be why the standard driver works and Teensy4_I2C doesn't. I'm planning to add that method (or something similar) in the next few weeks. In the mean time, you might be able to reset the I2C slave devices with hardware. Some devices has a reset pin that you could connect to the Teensy and trigger if you think the bus is stuck. You can tell if the I2C master failed by checking it's error code after a transfer. Use the underlying master device like this:
If you suddenly see every attempt to read a device trigger code 12 Trigger the reset pin if you see error code 12 |
Thanks again for the pointers, I haven't had a chance to go through all the debug steps but I am using i2c pins Using your master branch I added your error checking code and got this error:
I switched to the stuck_bus branch and the Teensy locked up (and could not recover) with these error messages:
In one attempt I saw one of the i2c MPR121 devices blinking as if it was stuck. After rebooting the Teensy, I got slightly different error messages (but it still locked up immediately and did not recover)
Unfortunately I don't see any reset pins on my i2c devices. |
When you say that you're using pins 17/18 do you mean that you've got a single I2C bus connected to pins 17 and 18 or do you have 2 buses with one connected to pins 18 & 19 and one to 16 & 17? Thanks for giving the If you've got an oscilloscope then you can use that to look for activity. If you haven't got a stuck slave then maybe:-
|
Oh my mistake -- I meant I have a single bus running on pins 18 & 19. I think you may be right that a slave is stuck, I'll take a closer look at that. |
Ok, so I removed all i2c devices except my i2c display and encountered this bug when simply replacing Wire with this library. Hopefully it is simple enough for you to reproduce.
|
Thanks for that. Do you have a link to the actual display you're using? I'm think of buying one so I can test it. |
Sure. This is the one I am using to test, though there appear to be lots of variations of this same display. |
I bought a display and it's working Ok for me. It works the same with Wire.h and Teensy4_I2C. I bought this display. The sheet which comes with it claims that it's an SSD1306. When I tried it with the SSD1306 driver it worked but had this problem. It works fine with the same SH1106 driver that you used. It worked whether I powered it off the 3.3V or 5V pin on the Teensy. Here's a picture of the wiring on my breadboard. It's possible that it works like this with short leads and no other connected devices but fails with a more complicated setup. What does your setup look like? Did you have any unused wires or any other devices connected to the bus? Here's the complete code that I used.
|
Interesting. Did you encounter any issues running the u8x8 graphics test? I suspect the issue only comes up when the display is updating rapidly. My setup is definitely more complicated, but I don't think I had anything extra connected. I'll give it another try and let you know. |
The full example works OK too. The only thing I can think of is that the driver works well until something corrupts an I2C message and then it fails to recover. I know this happens if you have a dodgy bus wire. I've started to create some tools to try to diagnose these issues and create an automated test suite for the driver. Unfortunately, This is going to take a lot of time. I saw someone mention that powering an OLED from the Teensy's 3.3V line can introduce a lot of noise. Do you have yours connected to the 3.3 or 5V pin? |
Are you powering your Teensy through the USB connector? If not, which pin are you using for power and what's the voltage? |
Hm, so for whatever reason, I can't reproduce the display bug now. The display seems to work fine in isolation or when other i2c devices are connected. That suggests bad wiring, though I'm not entirely convinced just yet. It still seems odd that the error doesn't happen with the default Wire.h...but I could just be getting lucky with how Wire.h handles errors -- I suspect instead of timing out and crashing the entire bus just slows down. I have my display connected to the 3.3v. I tried 5v and encountered the same issues. Thanks for your help thus far. I think to get any further with this, I'm going to have to completely rewire everything and see if that fixes the problem. |
Actually, nevermind! After toiling for hours I think I solved it. It was a hardware issue with the pull up resistors for the differential extender. Whew... |
Hello, thanks for writing this library. It definitely solved many of the blocking/speed issues I was encountering! However after swapping out the Wire.h library for Teensy4 I2C now I'm bumping up against an intermittent time out error: "Timed out waiting for transfer to finish."
I am running a Teensy 4.1 with audio shield, several MPR121 capacitive touch sensors, and an OLED. The error seems to happen while reading from the MPR121 sensors. If I increase the clock speed, the error happens less frequently. If I disable the MPR121 sensors entirely, the error disappears. My first thought was maybe there is a conflict between Teensy4 I2C and the Adafruit MPR121 library, but I'm not entirely sure. I suspect it might also be a conflict with the Audio library.
Any help is appreciated!
The text was updated successfully, but these errors were encountered: