energia / tivac-core

7 stars 17 forks source link

issue with the begin function as master #39

Closed mavro10600 closed 4 years ago

mavro10600 commented 6 years ago

I had been trying to work with the i2c bus with a mpu6050, but it just did not work. So I added a while right after you enable the peripheral in the begin() function as master, it just worked out for me, i followed the tivaware reference guide example for i2c initialization

robertinant commented 6 years ago

Adding example Sketch @mavro10600 provided.

#include <Wire.h>

void setup()
{
  Serial.begin(115200);
  delay(100);
  Wire.begin(); // join i2c bus (address optional for master)

}
void loop()
{
  Serial.println("inicio");
  int8_t count = 0;
  uint32_t t1 = millis();
  // Wire.flush();
  Wire.beginTransmission(0x68); // transmit to device #4

  Wire.write(0x75);// sends one byte

  Serial.print("endtransmission");
  Serial.println(Wire.endTransmission()); // stop transmitting

  Wire.beginTransmission(0x68);
  Serial.print("requestfrom");
  Serial.println(Wire.requestFrom(0x68, 1));
  count = Wire.read();
  Serial.print(count, HEX);
  delay(1000);
}
robertinant commented 4 years ago

This patch was applied manually rather than merging the pull request