Hi All,
Firstly - I am no I2C expert and am trying to connect the Teensy 3.2 to another, custom, digital I2C master device.
This other device uses a customized version of I2C as shown below. The first byte is the typical I2C address & R/W bit with the other bytes being custom data. There are no special commands like read or write to certain registers like the I2C data link layer uses.
Once the other device receives the payload4 it responds with a message like the one above. Below is a screen shot of the bus when the other device sends that response to the teensy. It appears that once the teensy latches the address, it pulls the bus low and keeps it low forever (shown in the picture). I did try changing "Wire.begin(MY_ADDR);" to "Wire.begin();", and that prevented the teensy from pulling the bus low, but it never did enter the onReceive callback. In another modified version of the attached code I would send another message to the other device from the Teensy after it pulled the bus low, and it would send, but it would return low again afterwards.
So, what do I need to do to get the teensy to correctly receive this message format over I2C?
Firstly - I am no I2C expert and am trying to connect the Teensy 3.2 to another, custom, digital I2C master device.
This other device uses a customized version of I2C as shown below. The first byte is the typical I2C address & R/W bit with the other bytes being custom data. There are no special commands like read or write to certain registers like the I2C data link layer uses.
Once the other device receives the payload4 it responds with a message like the one above. Below is a screen shot of the bus when the other device sends that response to the teensy. It appears that once the teensy latches the address, it pulls the bus low and keeps it low forever (shown in the picture). I did try changing "Wire.begin(MY_ADDR);" to "Wire.begin();", and that prevented the teensy from pulling the bus low, but it never did enter the onReceive callback. In another modified version of the attached code I would send another message to the other device from the Teensy after it pulled the bus low, and it would send, but it would return low again afterwards.
So, what do I need to do to get the teensy to correctly receive this message format over I2C?
Code:
#include <Wire.h>
#define MY_ADDR 0x3A
#define YOUR_ADDR 0x00
int number;
byte payload4[] = {0x20, 0xFA, 0x10, 0x11, 0x03, 0x01, 0x0F, 0x0F, 0xFF, 0xFF, 0x00, 0xBA};
void setup() {
Serial.begin(115200);
delay(5000);
Serial.println("working");
Wire.begin(MY_ADDR);
Wire.onReceive(receiveData);
}
void loop() {
Serial.println("\nHERE 1");
Wire.beginTransmission(YOUR_ADDR);
Wire.write(payload4, 9);
Wire.endTransmission();
delay(5000);
// 2nd device sends data to teensy here
// do nothing
while(1){};
}
void receiveData(int howMany){
while(Wire.available() > 0) {
char c = Wire.read();
// Serial.print(c, HEX);
// Serial.print(" ");
}
// Serial.println("");
}