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:
Here is the output to Serial:
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?
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?