Hi all.
So I want to use my little pico as secondary element in a setup where it handles some auxillary sensors and indicators, but talks to a raspberry pi. I was hoping to use i2c as I've been enjoying learning more about it and I was wondering if that was a possibility.
I see that there is some support in pyb for using a pyboard as an i2c device controlled by another device on the bus. I also noticed that CircuitPython has an i2c peripheral class in their main branch, though it is not yet in Circuitpython for pico (and they tell me probably wont be for some time)
But I've been enjoying learning more about micropython, I'm just wondering if anyone knows if that kind of support will be coming to micropython for the Pico. It makes me think maybe its a hardware limitation and I'd have to bitbang a solution, but I wondered if some easy solution existed and thought I'd ask here! Thanks for any insight you can offer.
Using Pico as an i2c peripheral?
Re: Using Pico as an i2c peripheral?
The RP2040 hardware does support I2C peripheral.directive0 wrote: ↑Fri Feb 05, 2021 4:19 pmBut I've been enjoying learning more about micropython, I'm just wondering if anyone knows if that kind of support will be coming to micropython for the Pico.
At a simple level, supporting it from MicroPython isn't too difficult (the SDK already has methods for it, and in gneral the machine API is just a wrapper around the SDK functionality).
However, the hard bit with I2C peripheral is coming up with a good API -- the main issue is that the IRQ handling needs to be very fast. I think there was some talk about supporting something higher level than the current pyb API (and try and support this on all platforms), i.e. something emulating a set of registers. You can set the value of registers and get notified when they change, but the actual handling of the I2C IRQs is done for you.
In the meantime though, I'd suggest using a UART instead to talk between devices.
-
- Posts: 2
- Joined: Fri Feb 05, 2021 4:13 pm
Re: Using Pico as an i2c peripheral?
Okay thank you for the advice. I will look into uart.