teensy 3.1 wire, failed to get a signal on I2C pins 18 19

Status
Not open for further replies.

Jantje

Well-known member
Hi
I have been playing with teensy 3.1 this weekend and I simply failed to get a signal on the I2C pins.
I have tested with 2 teensy's with and without pull-up resistors (10K) and a scope to see the signal.
Basically without the pullups the scope gives a flatline on 0V and with the pullups I get a flatline one 3.3V (or 5V depending on the pull up voltae used)

Both teensy's are fresh from the package.
I used arduino 1.0.6 and teensyduino 1.20
This is the code I run for testing
Code:
#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);
  delay(5000);
  Serial.println("starting");
}

byte x = 0;

void loop()
{
  Serial.print("loop");
    Serial.println(x);
  Wire.beginTransmission(4); // transmit to device #4
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte  
  Wire.endTransmission();    // stop transmitting

  x++;
  delay(50);
}
This is the sample program where I added serial monitor prints to verify the program is running. The serial monitor receives the output.
I reinstalled the whole software stack (in a blank folder) to make sure no bad libraries were picked up.
Nothing seems to get me a signal.
Any help would be appreciated.
Best regards
jantje
 
I'm running your code here, using a Teensy 3.1 and two 10K pullup resistors. It seems to be working fine.

i2ctest.jpg

file.png
(click for full size)
 
Of course, there aren't 6 data bytes, because no I2C device is listening at address 4 and responding with an ACK.

Wire.endTransmission() is returning an error code, because no device is present. You can see it with this:

Code:
#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);
  delay(5000);
  Serial.println("starting");
}

byte x = 0;

void loop()
{
  Serial.print("loop");
  Serial.print(x);
  Wire.beginTransmission(4); // transmit to device #4
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte  
  int result = Wire.endTransmission();    // stop transmitting
  Serial.print(", result = ");
  Serial.println(result);
  x++;
  delay(50);
}

Even though there's an error, it's pretty easy to see the activity on the SDA and SCL pins.

Pullup resistors are absolutely required.
 
Hi Paul
Thanks for your answer.
The behaviour you see is exactly what I expected, but I don't seem to be able to get it here.
I wouldn't trust myself with a scope, but I was at a jam and asked someone knowing how to work with a scope and he didn't find any signal.
I'm actually thinking something is wrong with the included libraries/compilation setup on my system. Could you post the hex file so I can upload your compiled code to rule out the development environment problem?
Best regards
Jante
 
Here it is.
Thanks paul.
The good news is: your sketch is working. I have the same imae on my scope now.
The wierd thing is that when I compile and upload the sketch now on my system it seems to work as well. I'm all bafled but last weekend nothing seemed to work for me anyways, so I think that explains it.
I'll have to dive into this but that will probably be in the next arduino jam in februari 2015.
Best regards
Jantje
 
Status
Not open for further replies.
Back
Top