![]() A lot of the details however will be of more general interest. This post describes how the I2C (Inter-Integrated Circuit, or "Two-Wire") interface works, with particular reference to the Arduino Uno which is based on the ATmega328P microprocessor chip. ![]() This page can be quickly reached from the link: ![]() The data is now being transferred both ways between the 2 Nano masters and the Mega slave at the correct interval, without corrupt data.A summary of everything shown below is available further down this page: The data is then filtered on each master to only keep the relevant information. The slave has to send the data destined to both masters to each of them because requestEvent can't tell which master is asking for data. The bus speed also had to be reduced because 800 kHz was too fast for the Mega 2560 (but worked between 3 Nano). I figured these out after asking question #35092 Half of the data was wrong without this filter (this should ideally be handled in the Wire library) I added an if statement to compare the receiveEvent data size with the expected size. ReceiveEvent, on the slave side, was also confusing real data with incoming requestEvent. ![]() I moved the timer to the master side before calling Wire.requestFrom. ReceiveEvent, on the slave side, contained a millis if condition timer that made it time out. The second master was then behaving the same and so on. This made it keep the bus too long and eventually give it away to the second master at a random time, with missed transfers from the second master in between. ![]() The code had several issues leading to a constant flow of wrong data (with correct data in the middle) between the master that won the bus arbitration. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |