I2c requestFrom() Question

Status
Not open for further replies.
First post, I've used Teensy on other projects but not with i2c. I'm not sure what's going on here but it's probably pretty simple.

Teensy 3.2 talking to a MAXREFDES117 pulse ox chip on eval board. It comes with stock code for the Uno and I've been attempting to convert it to the Teensy. Below is the output of the stock code I'm trying to emulate.
Uno Stock.jpg

Here is the code I'm using:
Code:
#include <i2c_t3.h>

void setup() {
  Wire.begin();
  Wire.setClock(25000);
}

void loop() {

  Wire.beginTransmission(0x57);
  Wire.write(0x00);
  Wire.endTransmission(false);          // start repeat
  
  Wire.requestFrom(0x57,1);
  //byte blah = Wire.read();
  Wire.endTransmission();
  
  delay(5000);
}

And here is the result:
Teensy Output.jpg

My question is: Why are address 0x57 and data 0x00 written after the read attempt? Uncommenting Wire.read() changes nothing. Same issue with 100 kHz clock. Same issue with standard Wire library.

Thanks in advance.
 
I seem to have found a solution so I thought I'd include it here for others. I was under the impression that all i2c communications had to end with endTransmission(), but this is not the case. The code below produces the desired result, identical to the first image posted above.

Code:
#include "i2c_t3.h"

void setup() {
  Wire.begin();
}

void loop() {

  Wire.beginTransmission(0x57);
  Wire.write(0x00);
  Wire.endTransmission(false);          // start repeat
  
  Wire.requestFrom(0x57,1);
  
  delay(5000);
}
 
Status
Not open for further replies.
Back
Top