I2C2 now working on pico? #736
Replies: 25 comments
-
Posted at 2015-04-22 by @gfwilliams Just a quick check:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 No pullups no, although can try tonight. PS. You may get a few pull requests from me on github for a couple of modules, not having I2C working properly has forced me to make a few changes so they dont hang and break the rest of the execution. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams I'd definitely try some pullups - it might have just been on the edge of working with I2C1. However it might be that your SSD1306 LCD has them built in anyway - worth a try though. That's great about the PRs - thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams Just looking into this - it's a bug, and I should be able to fix it for the next release. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams Ok, fixed! In an hour or so there'll be a build for the Pico in: http://www.espruino.com/binaries/git/commits/34e8f0101f73604d3ffc3db0a36816302e5c8a23 Instructions on using it at the top of http://www.espruino.com/Download |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 Okay not a problem, it started because I couldn't talk to two I2C devices at once on the same I2C1 bus. And when i say cant, i mean it really messes things up. If i try to communicate with another devices it locks up the stream and i get "Timeout on I2C Write BUSY". Im wondering if its because the whole I2C way of communicating is a singleton. Looking into now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 Sweet, many thank! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams I2C should work with many devices on a bus, but there are sometimes some issues:
Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 Okay thats good, could you give an example of doing this? I keep getting Timeout on I2C Write BUSY |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams Just did this with a SSD1306 OLED and an HD44780 16x2 LCD:
It's as easy as just setting I2C up once, and then using it multiple times. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 Ahhh i see, so for others reading this here is where i went wrong. I2C1 needs to be called within scope of what your communicating with, im guessing its a state machine, so when you call ".connect(I2C1)" you taking control away from other modules that are using. When i see "require" i automatically think they need to be grouped at the top all pretty, but they dont. I was trying to do:
this doesnt work! what i needed was
Many thanks for your help Gordon! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams I think in this case it might have been because you were using I2c1 in the modules before it had been set up? Possibly even:
Would have been fine... The other issue is that usually you do:
The function gets called when the display is initialised, which is actually after a slight delay. What you were doing with getting the pressure and then immediately writing to the display might have been trying to send stuff to the display before it had actually initialised. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by Spocki @gordon Thanks alot, was struggling with this, too. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 The top one doesnt work, i was doing the setup, just ommited it in my example. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 iv also ran into more problems with the SSD1306 display. if you increase the font size to more than about 4 (so its actually readable) it crashes.
very strange. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by DrAzzy Huh! g.setFontVector() used to work - I remember someone using it to get 2 digits to fill a PCD8544 with the temperature... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by user54499 unless im doing somthing wrong it no workie. Heres the code:
if i increase the fontsize variable beyond 4 it freezes up (sometimes loops a couple of times) seems like a leak or overflow somewhere. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-22 by @gfwilliams I think your problem is partially that you're re-initialising the display each time. Try:
There is however some regression issue when re-initialising the graphics multiple times, that I did notice recently and try to fix this morning (I fixed one problem, but haven't quite solved it yet). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-23 by user54499 Okay, it does work thanks for your help Gordon, it was indeed because i was initialising each time. The code that eventually worked properly was
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-23 by @gfwilliams Ok, try:
So initialising the display, and then initialising everything else in its callback. If that doesn't work it could be the BMP085 is messing things up somehow when it's not initialised, so you could try doing it first:
Re-initialising the display each time really isn't a solution (it'll flicker massively every time you update it). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-23 by user54499 its all working now, although i have to reset the pico alot as the i2c bus locks up. is there any way to safely stop the i2c stuff? and or is there a better way of reseting other than re-plugging it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-23 by alexanderbrevig Did you add the pullup resistors @user54499? They are necessary to keep a reliable state on the bus. Devices that are inherently slaves should not have pullups (though some will have them in 20k-100k range and will provide a weak current).
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-23 by DrAzzy I actually have had problems doing this in the past with the BMP180 specifically; almost identical configuration actually, doublebuffered display and BMP180 on same I2C bus; sometimes the BMP180 just seemed to get pissed off and start holding the bus low. I kept thinking it was wiring - and sometimes it reacted as if it was - but there was also behavior I couldn't reconcile with a hardware explanation. Plus I didn't get accurate data from it when it was inside my device, while it worked fine on the bench. I eventually gave up and have it disconnected. Never did figure out why it would go off the rails like that, but it failed with 3 different BMP180's, but they'd all work fine when I tried to test on the bench, and it failed with three different wiring setups as well (2 home-made PCB's and before that with wires) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-24 by user54499 Its a bit finicky at best for the BMP085.I submitted some code changes on Github which should help out a lot, instead of just locking the I2C bus permanently, it should just return null and let you try again. Previously if your BMP fails to init for some reason, you have to do a FULL reset and re-upload! Looks like the changes are now live. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-04-24 by @gfwilliams The new firmware 1v77 that's now out actually has the I2C2/3 support fixed, so if reliability is a problem you could just stick each device on its own port again. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-04-22 by user54499
Hi All!
Impressed with the pico so far, but im stuggling to get the I2C2 bit working. Testing with the following code for an OLED, but iv tried other I2C devices to no avail on the second bus.
any help appreciated
Beta Was this translation helpful? Give feedback.
All reactions