Skip to content

Teensy 3.6 multi-master configuration not working.  #26

Description

@vveliev

I have issues using this lib with multi-master configuration:

The example code provided below(if replace with Wire lib, the code does work on Arduino uno/mega)

Master1:

#include <i2c_t3.h>
//#include <Wire.h>

#define I2C_ADDRESS_OTHER 0x2
#define I2C_ADDRESS_ME 0x1

void setup() {
    Serial.begin(9600);
    Wire.begin(I2C_MASTER, I2C_ADDRESS_ME, I2C_PINS_18_19, I2C_PULLUP_EXT, 100000);
//    Wire.begin(I2C_ADDRESS_ME);
    Wire.onReceive(receiveI2C);
}

void loop() {
    delay(5000);
    Wire.beginTransmission(I2C_ADDRESS_OTHER);
    Wire.write("hello world from 0x1 to 0x2");
    Wire.endTransmission();
    Serial.println("Send to master2");
}

void receiveI2C(size_t howMany) {
    while (Wire.available() > 0) {
        char c = Wire.read();
        Serial.print(c);
    }
    Serial.println();
}

Master 2:

#include <i2c_t3.h>
//#include <Wire.h>

#define I2C_ADDRESS_OTHER 0x1
#define I2C_ADDRESS_ME 0x2

void receiveI2C(size_t count);

void setup() {
    Serial.begin(9600);
//    Wire.begin(I2C_ADDRESS_ME);
    Wire.begin(I2C_MASTER, I2C_ADDRESS_ME, I2C_PINS_18_19, I2C_PULLUP_EXT, 100000);
    Wire.onReceive(receiveI2C);
}

void loop() {
    delay(5000);
    Wire.beginTransmission(I2C_ADDRESS_OTHER);
    Wire.write("hello world from 0x2 to 0x1");
    Wire.endTransmission();
    Serial.println("Send to master1");
}

void receiveI2C(size_t count) {
    while (Wire.available() > 0) {
        char c = Wire.read();
        Serial.print(c);
    }
    Serial.println();
}

I2C bass spesifications tells me that it should be working hardware wise.
https://www.nxp.com/docs/en/user-guide/UM10204.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions