Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: I2C Slave on Teensy 4

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    5

    I2C Slave on Teensy 4

    Hi. I've just started using a Teensy for the first time. I'm trying to get a Raspberry Pi to talk to a Teensy 4 over I2C. I've configured the Teensy to listen in slave mode but it doesn't seem to be listening. (See code below)

    I did a bit of digging and found this in WireIMXRT.cpp.
    Code:
    void TwoWire::begin(uint8_t address)
    {
    	// TODO: slave mode
    }
    Does this mean that the Teensy 4 doesn't support I2C slave mode? If not, what protocol would you suggest for communication to a Raspberry Pi?

    Here's my code for the Teensy. Is there something wrong with it?

    Code:
    #include <Arduino.h>
    #include <Wire.h>
    void i2c_slave_request_ISR();
    void i2c_slave_receive_ISR(int count);
    void setup() {
      Wire.onRequest(i2c_slave_request_ISR);
      Wire.onReceive(i2c_slave_receive_ISR);
      Wire.begin(8);
    
      Serial.begin(9600);
      Serial.println("Started");
    }
    void loop() {
      delay(1000);
    }
    void i2c_slave_request_ISR() {
      Serial.println("Got I2C Request");
    }
    void i2c_slave_receive_ISR(int count) {
      Serial.println(" Got I2C Receive Request");
    }
    thanks very much,
    Richard

  2. #2
    Junior Member
    Join Date
    Oct 2019
    Posts
    5
    To answer my own question...

    I2C Slave mode is definitely not supported by the current version of Wire. The Teensy 4 isn't supported by the i2c_t3 library either.

    I've started to write a new driver that extends Paul's version to add Slave mode. I'll be happy to share this with everyone as soon as it's usable. Please let me know if you're interested in using it. If you've got any other problems with I2C and the Teensy 4 I might be able to deal with them as well.

    cheers,
    Richard

  3. #3
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,103
    You are correct. I2C slave mode isn't supported yet on the T4. Currently in the wire lib there are places that identify that.

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,198
    FWIW, the NXP SDK for the 1060 has an I2C slave example
    boards/evkmimxrt1060/driver_examples/lpi2c/interrupt_b2b_transfer/slave/

  5. #5
    Junior Member
    Join Date
    Oct 2019
    Posts
    5
    Thanks manitou. I didn't know about the SDK. I'll check it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •