After a several tests and after to try the different issues in post viewtopic.php?f=6&t=597&start=10, I come towards you for you help.
I try to communicate in I2C interface with the two pyboard. On in Master and another in Slave, of course.
I use the Pyb.I2C module (no machine.I2C).
I follow the topic (issue) above and I can :
- scan my Slave,
- receive a data from Master to Slave (Master -> Slave),
but when I try to receive a data from Slave to Master (Slave -> Master), i don't recover a good data.
I see in the web several person who post the example for I2C.MASTER implementation but much less for the I2C.SLAVE.
I try the example of code of blmorris post #340 in viewtopic.php?f=6&t=597&start=10.
Code: Select all
#For master
from pyb import I2C
i2cM = I2C(1, I2C.MASTER)
i2cM.init(I2C.MASTER)
#Launch the receiv commande for the slave and continu with
i2cM.send('ABC', addr=0x42)
#I receive the good 'ABC' in the slave - Ok !
#Launch the send commande for the slave and continu with
i2cM.recv(3, addr=0x42)
#I receive for the master only >> b'\x0c\x00\x00' or b'\x00\x00\x00'
Code: Select all
For the slave
from pyb import I2C
i2cS = I2C(1, I2C.SLAVE)
i2cS.init(I2C.SLAVE,addr= 0x42)
i2cS.recv(3,addr=0x42, timeout=-1)
#Launch the send command for the master and continu with
i2cS.send('ABC', timeout=-1)
#Launch the receive commande for the master.
For my tests, I use the two pyboard PYBV1.0 and PYLITEv1.0 upgrade with the lasted révision of micropython.
- MicroPython v1.8-66-gcc80c4d on 2016-05-13; PYBv1.0 with STM32F405RG
- MicroPython v1.8.3-8-gaf9889f on 2016-08-12; PYBLITEv1.0 with STM32F411RE
Does someone there an idea ?