Skip to content

M4 I2C as slave #45

@freemovers

Description

@freemovers

I2C slave on the M4 is not working using the standard sketch:

    #include <Wire.h>

    void setup() {
      Wire.begin(8);                // join i2c bus with address #8
      Wire.onReceive(receiveEvent); // register event
      Serial.begin(115200);      // start serial for output
    }

    void loop() {
      delay(50);
    }

    // function that executes whenever data is received from master
    // this function is registered as an event, see setup()
    void receiveEvent(int howMany) {
      Serial.println("active");
      while (1 < Wire.available()) { // loop through all but the last
        char c = Wire.read(); // receive byte as a character
        Serial.print(c);         // print the character
      }
      int x = Wire.read();    // receive byte as an integer
      Serial.println(x);         // print the integer
    }

It will lock up the board running the Master sketch. Using an Feather M0 as a slave works fine.

See comments on the Adafruit forum as well: https://forums.adafruit.com/viewtopic.php?f=63&t=135452

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions