I2C slave doesn't receive two bytes

Hi there
My master is an STM32F303 and the slave is the Argon. I try to transmit 2 Data bytes but the Argon receives correctly only the 2nd byte transmitted, the 1st byte is always shown as 255d (0xFF) on the serial monitor. I checked the transaction with the scope, and everything looks OK.
Here my code:

void receiveEvent(int howMany) {
  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
  }
  uint8_t STdataH = Wire.read();
  uint8_t STdataL = Wire.read();

  Serial.println(STdataH);
  Serial.println(STdataL);
}

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

void loop() {
  delay(100);
}

Here a screenshot from the scope:

Thanks for any help

If you only leave one byte in the buffer, how would you then read two?

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.