Pyboard as i2c slave won't work
Re: Pyboard as i2c slave won't work
I just tried the code from you guys and it works great. Thanks a lot. Now all I have to do is try to understand why it works and what I need to do to get the rest of the project done. But thanks for the help for now.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Pyboard as i2c slave won't work
The solution might be to add an extra link between master and slave, whereby the slave can raise an interrupt on the master. In terms of the communication protocol the slave would be "Active" and the master "Passive". "Passive" would prepare any data to be sent, set up a receive buffer, and wait for an interrupt. "Active" would periodically initiate communications by pulsing the line. The communication would then occur.OutoftheBOTS_ wrote: ↑Wed Oct 03, 2018 2:52 am...The Slave has to be constantly monitoring for data from the master or the master will receive a NACK. This sort of made it not useful, as the slave device can't really go off and do things or the master will get a NACK back...
The point here is that the slave ("Active") is the participant which is liable to block for long periods, so you ensure that blocking is for the minimum possible time. The same could be achieved without the extra wire if Passive polled I2C.is_ready(addr), but this would have higher latency and be less efficient.
I'm interested in getting a uasyncio-friendly communications link working; I can feel an experiment coming on...
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Pyboard as i2c slave won't work
I think that's the accelerometer.SpotlightKid wrote: ↑Tue Oct 02, 2018 2:35 pm...
(Obviously, there are other, internal I2C slaves connected to I2C bus 1.)...
Thanks for that useful code sample
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: Pyboard as i2c slave won't work
I have an i2c thermometer/ humidity sensor.
It constantly waits for the master to write a command/register pair at which point it reacts taking a couple of milli seconds then returns to a read loop/ blocking read.
If your setting up your pyboard to be a slave it probably needs a dedicated thread to deal with the master slave comms and one to measure all your other sensors.
It constantly waits for the master to write a command/register pair at which point it reacts taking a couple of milli seconds then returns to a read loop/ blocking read.
If your setting up your pyboard to be a slave it probably needs a dedicated thread to deal with the master slave comms and one to measure all your other sensors.