Teensy 3.1 I2C communication (Where are SDA & SCL)

Status
Not open for further replies.
On the Teensy 3.1, where are the I2C pins (SDA, SCL) located?

I ~thought~ it was pin 18 & 19.
I loaded the code below. I have (2) 4.7k resistors on the I2C inputs on my MCP23008.
When I put my oscilloscope on SDA or SCL, there is NO transmission, just 3.3V steady.

Complete code for good measure:
Code:
#include <Wire.h>

void setup() {
   Wire.begin();                      // initialise the wire library and hardware

   Wire.beginTransmission(0x40);      // start talking to the device
   Wire.send(0x00);                   // select the IODIR register
   Wire.send(0xff);                   // set register value-all high, sets all pins as outputs on MCP23008
   Wire.endTransmission();            // stop talking to the devicevice
   
   pinMode(13, OUTPUT); 
}
void loop() {
   Wire.beginTransmission(0x40);      // start talking to the device
   Wire.send(0x09);                   // select the GPIO register
   Wire.send(0xff);                   // set register value-all high
   Wire.endTransmission();            // stop talking to the device
   
   digitalWrite(13, LOW);

   delay(500);                        // wait for 1/2 a second

   Wire.begin();                      // initialise the wire library and hardware

   Wire.beginTransmission(0x40);      // start talking to the device
   Wire.send(0x09);                   // select the GPIO register
   Wire.send(0x00);                   // set register value-all low
   Wire.endTransmission();            // stop talking to the device
   
   digitalWrite(13, HIGH);

   delay(500);                        // wait for 1/2 a second
}
 
Some thoughts:

Just to be sure, for the 4.7k resistors, you have wired them as pull-up resistors (resistor goes between data pin and 3.3v), and NOT between the data pin and ground?

Have you considered trying to put the resistors on the Teensy, rather than the MCP23008?

Finally, you have hooked up 3.3v to the MCP23008 VCC pin and ground to the MCP23008 ground? Not using either the VCC or VUSB pins on the Teensy.
 
it's easy to forget that loop() gets called repeatedly.
I always code a while (1) to remind me, and I don't have to wonder what happens if anything should loop() return.

but yes, there are several .begin() calls as well.
 
Some thoughts:

Just to be sure, for the 4.7k resistors, you have wired them as pull-up resistors (resistor goes between data pin and 3.3v), and NOT between the data pin and ground?

Have you considered trying to put the resistors on the Teensy, rather than the MCP23008?

Finally, you have hooked up 3.3v to the MCP23008 VCC pin and ground to the MCP23008 ground? Not using either the VCC or VUSB pins on the Teensy.

Yes, the 4k7 resistors are between VCC (+3.3) and the I2C pins. I left them closer to the MCP23008 to give me the flexibility to move my jumper wires until I find the two pins (SDA, SCL) on the Teensy that pull to GND in an I2C manner. The Teensy and the MCP23008 share the same power and ground (3.3V & GND).

I have two "benches". One is the laptop with a program cable. There, the power is from the USB. The total current is less than 35mA. My other bench has power supply and a rather dated 60MHz scope. Here, I power up the breadboard with the supply and monitor the pins with the scope. Neither pins 18 & 19 nor pins 16 & 17 show any activity.

Why do you call Wire.begin so many times?

but yes, there are several .begin() calls as well.

As for the extra Wire.begin()....I have one in setup. I only see one extra in the middle of the loop. I see a lot of Wire.beginTransmission, but I expect a lot of those. :)
 
Code:
digitalWrite(13, LOW);
delay(500);                        // wait for 1/2 a second
Wire.begin();                      // initialise the wire library and hardware

Look at this portion of loop(). This begin is not needed because you had one in setup().
 
Last edited:
I noticed in some other code that if Arduino was >= 100, then "Wire.write()" was used instead of "Wire.send()".

Anybody know the difference between the two? What ?number? is the Teensy 3.1?
 
Last edited:
The change was made in the Arduino 1.0 release (when 1.0 came out, ARDUINO was 100*major release + minor release, so it would be 106 for Arduino 1.0.6 -- I don't know if they use a different scheme now that 1.6.x has come out). I vaguely recall that ARDUINO was not defined until the 1.0 time frame, and in the context of #if statements, an unknown identifier is replaced with 0.

Since the Teensy only supported 1.0.5 as the minimum Arduino release (now 1.0.6), you don't need the code where ARDUINO is either not defined or less than 100, unless you want to run with an old release such as 0.22 Arduino on an Arduino Uno.
 
Last edited:
Status
Not open for further replies.
Back
Top