Teensy 3.1 hangs on Wire.endTransmission()

Status
Not open for further replies.

EK701

Well-known member
Teensy 3.1 with Adesto RM24P NVRAM connected to SDA/SCL (18/19). Trying to get I2C working, but it's hanging on Wire.endTransmission(). I found several other threads on the same problem, but I did not see a resolution on any of them. Here is a basic I2C scanner sketch that hangs:

Code:
// -------------------------------------------------------------------------------------------
// Teensy3.0/3.1 I2C Scanner
// 08Mar13 Brian (nox771 at gmail.com)
// -------------------------------------------------------------------------------------------
//
// This creates an I2C master device which will scan the address space and report all
// devices which ACK.  It does not attempt to transfer data, it only reports which devices
// ACK their address.
//
// Pull the control pin low to initiate the scan.  Result will output to Serial.
//
// This example code is in the public domain.
// -------------------------------------------------------------------------------------------
#define I2C_DEBUG

#include <i2c_t3.h>
#ifdef I2C_DEBUG
#include <rbuf.h> // linker fix
#endif

// Function prototypes
void print_scan_status(uint8_t target);

void setup()
{
  pinMode(13,OUTPUT);       // LED

  Serial.begin(115200);
  delay(4000);

  // Setup for Master mode, pins 18/19, external pullups, 400kHz
  Serial.println("Init I2C");
  Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_400);
  Serial.println("End init I2C");
}

void loop()
{
  uint8_t target; // slave addr

  //
  // Test1/2 - scan I2C addresses
  //
  Serial.print("---------------------------------------------------\n");
  Serial.print("Starting scan...\n");
  digitalWrite(13,HIGH); // LED on
  for(target = 1; target <= 0x7F; target++) // sweep addr, skip general call
  {
    bool error = true;
    while (error) {
      Serial.print("Target is ");
      Serial.println(target);
      Serial.println("Wire begin");
      Wire.beginTransmission(target);       // slave addr
      Serial.println("Wire end");
      error = Wire.endTransmission();               // no data, just addr
      Serial.println("Print scan status");
      print_scan_status(target);
    }
  }
  digitalWrite(13,LOW); // LED off
  Serial.print("---------------------------------------------------\n");

  delay(500); // delay to space out tests
}

//
// print scan status
//
void print_scan_status(uint8_t target)
{
  switch(Wire.status())
  {
  case I2C_WAITING:
    Serial.print("Addr 0x");
    Serial.print(target,HEX);
    Serial.print(" ACK\n");
    break;
  case I2C_ADDR_NAK:
    Serial.print("Addr 0x");
    Serial.print(target,HEX);
    Serial.print("\n");
    break;
  default:
    break;
  }
}

Here is the output to Serial:

Init I2C
End init I2C
---------------------------------------------------
Starting scan...
Target is 1
Wire begin
Wire end

And that's where it hangs. Both SDA and SCL are low (~0.8V) when it hangs. I haven't put a scope on SDA/SCL yet, but I will tomorrow. It hangs using both the standard Wire library and i2c_t3 library. I confirmed the wiring is correct and have 4K7 external pullups.

Ideas?
 
This is what I use to detect an I2C peripheral:

Code:
    for (int address=1; address <= 126; address++) {
      Wire.beginTransmission(address); // Select address
      if (!Wire.endTransmission())  Serial.printf("Found device at: %02Xh\n", address);
    }
 
This is what I use to detect an I2C peripheral:

Code:
    for (int address=1; address <= 126; address++) {
      Wire.beginTransmission(address); // Select address
      if (!Wire.endTransmission())  Serial.printf("Found device at: %02Xh\n", address);
    }

Thanks I'll try that.
 
I put the scope on the SDA and SCL lines and they hold steady low at 0.8v. I double checked the wiring and it is good, too. I also upgraded to Arduino 1.0.6 and Teensyduino 1.20rc4.

Any ideas?
 
Last edited:
Do you actually have the pull-up resistors connected ? to 3.3 V ? Are they 4.7 kohm ? 0.8 V seems strange -- if the output pulls low, it should be << 0.1 V.
 
Write a short program to set pins 18 & 19 as digital outputs and write a '0' -- do you see 0.8 V (wrong) or < 0.1 V (good) ?; then configure the pins as a digital inputs and the voltage should be 3.3 V
 
Write a short program to set pins 18 & 19 as digital outputs and write a '0' -- do you see 0.8 V (wrong) or < 0.1 V (good) ?;

I see <0.1V

then configure the pins as a digital inputs and the voltage should be 3.3 V

Voltage is 0.8v at the SDA/SCL pins on the NVRAM. I also checked the voltage at the 4.7k resistor. On the +3.3v side I have ~3.3v. On the I2C bus side, I have 0.8v.
 
Here's the relevant part of the schematic:

I2C.jpg
 
Although the schematic looks correct, check the physical wiring, and the way the MVRAM IC is oriented.
 
Although the schematic looks correct, check the physical wiring, and the way the MVRAM IC is oriented.

That's what I thought first, too. It looks right, but that SOIC-8 package is pretty small. I think I'm going to breadboard it. I have a Teensy 3.1 on a breakout board. Waiting on a SOIC-8 breakout board since my attempt at hand soldering one overheated the chip. Good thing they are cheap...
 
If you remove the NVRAM chip, does the voltage on SDA and SCL go back to 3.3V?

Is the NVRAM chip getting hot?

If it were connected backwards, it's VCC pin would be connected to GND. The SDA signal would be on E0 and the SCL would be on E1. Assuming it's not 5V tolerant, its protection diodes to VCC would be conducting current from those 4.7K resistors down to ground, and the forward drop on those diodes could be about 0.8V.

But if the chip were placed backwards, GND would be on VCC also, causing the chip's substrate to conduct a large current, which should get the chip really hot (and probably destroy it).
 
Chip isn't getting hot. I hate to desolder it right now. I think I'll wait to see how the breadboarding goes.
 
I bread boarded a Teensy 3.1 and the NVRAM chip. I used the same 3.3v dc-dc power and used 4.7k pull ups on SDA/SCL and the Teensy sees the NVRAM chip using a basic I2C scanner sketch. It's wired exactly as shown above in the schematic. Now I'm really stumped. Only thing I can think of is the NVRAM either got smoked when I soldered it to the PCB or I have a bad solder connection. Off to check the board again...
 
Status
Not open for further replies.
Back
Top