Teensy 4.0 I2C questions and issues

Status
Not open for further replies.

kdharbert

Well-known member
I have a Teensy 4.0 and I need to make an I2C magnetometer work using the SDA1\SCL1 pins. Like many others, I am seeing my sketch hang when endtransmission is called.

I a recent thread states wire.h does not support Tennsy 4.0 yet, but there is another library. The other library has a timeout on the endtransmission call and displays a message that the called failed.

I have 4.7k pullup resistors in place. I measured them with a scope an got 3.3 volts. (Normal) I also set a trigger on my scope to catch the edges on SDA1 and SCL1 during the I2C traffic. No edges were observed. This places the issue on the Teensy and code.

What could I have done wrong to never see voltage transitions on either I2C pins? The new library I used that shows there error message is here:
https://github.com/Richard-Gemmell/teensy4_i2c
 
I've used I2C on both the Teensy 4.0 and 4.1 with the standard Wire library included with Teensyduino. Haven't seen any hangs when endTransmission() is called. 4.7K pullups on both SDA and SCL.

You mention that you're using SDA1 & SCL1. I happen to also be using SDA1 & SCL1 rather than SDA0 and SCL0 (which are taken up in my program by CTS3 and RTS3), communicating with an MCP23017 that talks to an old daisy wheel printer with a Centronics parallel port.

I'll ask (because I did this in early testing and couldn't figure out why nothing worked:confused:); you are using Wire1 in your calls rather than just Wire, correct?
 
Yes, wire1. If nothing else, I figured I'd see a clock signal.
I reviewed the other thread I read, and its only slave mode they were saying doesn't work yet. So that makes sense now.
 
Indeed Master mode has Wire & 1 & 2 support in Wire.h with latest TeensyDuino for T_4.0 and 4.1.

Paul made a test board with 7 devices { and a qwIIC connect for each bus } on that could be selected on any Wire 0/1/2 bus and found and used for testing

What is the 'I2C magnetometer' in use in post #1?
 
Well, that would have been too easy if that had been the problem.

More dumb questions just to cover the obvious things I can think of.

Did you forget the Wire1.begin();?

Are you connecting to the correct output pins (SCL1 16, SDA1 17)?

Short of seeing the code and maybe a photo of the circuit, that's all I can come up with.
 
Can't have missed wire1.begin, or the hang behavior wouldn't reproduce. Yes, those are the pins...even if they're reversed there should be signal on the scope...but no.

There's a lot of other stuff going on on the board, and I have some add-ins wired under others so a picture will be tough. Is there I any chance the Teensy supplying too much power to the collection of other units could cause the I2C to drop out?
 
Speculating on a circuit and components I have no knowledge of wouldn't help you much I'm afraid. But if that's what you think it might be, a breadboard with just the Teensy and your unnamed magnetometer running a test sketch might at least rule that in or out. Good luck!
 
The magnetometer is a QMC5883L.
I'm using basically this code, only with wire1...
https://stackoverflow.com/questions/60272297/converting-arduino-compass-signal-to-useable-heading

Regarding the libraries...I changed back to wire1.h, and I no longer see endtransmission hang. I wish I knew what I changed...
However, I still see no clock or data edges on either line...even with the magnetometer removed, so I know its not that.

I have lots of serial, SPI and interrupts going on as well..any chance there could be a timer conflict or similar?
Also, I see none of the code examples setting pin modes for I2C lines. Is that handled in the Wire calls?

[Edit]
I removed the pullup resistors to check if the Teensy was having trouble driving the pins down from high. It seems that pin 16 (SCL1) on my Teensy4 is stuck outputting about 1.4v. I set it to output mode and set it both low and high...no change. I rechecked my pin assignments and old code that shouldn't have been working (?!) was taking over that pin for the ADC. Everything's fine now.
 
Last edited:
Status
Not open for further replies.
Back
Top