Open thunders82 opened 1 year ago
Given the device is single core, it can only service one interrupt at a time. That said, since I2C communication is relatively slow, it is not a problem to handle multiple channels. A normal case might be to have one bus dedicated to something like I2C display output, while another bus is reading from sensors.
In addition, a single Master can only communicate with one Slave at a time (it can of course talk to multiple Slaves, but only sequentially). However Teensy devices can setup multiple Master (or Slave) devices, and each can operate independently. For instance Wire as Master, and Wire1 as Master, and Wire2 as Slave. They will generate and service interrupts independently.
Refer to example "advanced_loopback" which shows a setup for single device running one Master and three Slaves (all wired together, hence loopback). That example is using sequential communication from the Master side, but it is also handling Slave interrupts on the same device. Similarly as a test it could be modified to be two Masters and two Slaves (with separate wiring one Master to one Slave), and then have them communicate continuously at different speeds. It should work.
Hi Nox, Thank you for your reply. Would you use the teensy multithreading library or do you have another recommendation?
Is it mandatory to have different speed for each master? And if yes, why?
Thank you
Regarding I2C operation, It is not required to use multithreading library to run multiple Wire instances (Wire, Wire1, etc..). I have not heard feedback from anyone using multithread lib in their main program, while also using i2c_t3 lib. I would expect it works okay.
It is not required to have different speeds for each Master. You can set it however you want.
Hi Nox, Thank you for your answer. I'll try to give it a go with multithreading as I'd like to send messages simultaneously on different Wire.
Hi, Is it possible to send and receive data on multiple i2c channels simultaneously? Thank you