Oled onPin 24 and 25 Teensy 4.1

Status
Not open for further replies.

yentz

Member
Hi,
referring to the pinout the pins 24 and 25 can be used as SDA and SCL.
However I dont get any device shown when trying the scanner and chaging the pins and uncommenting.
Also the getting started guide isnt quite clear. Do I have to use pull up resistors? Can I use several I2C devices on the same bus when using pullup resistors?
Thanks for helping
Jens
 
Yes I2C bus always needs pull-ups, but often I2C slave modules already have them. For the teensy these must only pull to 3.3V
of course. 4k7 or 10k are the common values you'll see.

And its a bus, so you can have more than one device so long as their I2C addresses are distinct.
 
Sample code? 24/25 are not the standard i2c pins (which are 18/19) so i think you would need to do Wire.setSDA/setSCL to use that pins.

Multiple I2C devices are possible, pullup resistors (2k2 / 4k7) are recommended.
 
Warning: Note pins 24 and 25 are I2C pins, BUT they are not alternate pins for the Wire object, instead they are on a different buss.
You instead need to use the Wire2 object, in the same way that pins 16 and 17 you use the Wire1 object.
 
Hi Kurt,

Thanks for bringing this up. But it also got me confused with respect to Wire.setSDA/setSCL.

If I understand correctly there are 3 I2C buses on Teensy 4.x and have to be invoked as:
Code:
Wire.begin();  // first bus, pins 18 & 19
Wire1.begin(); // second bus, pins 16 & 17
Wire2.begin(); // third bus, pins 24 & 25
Teensy 3.x has 2 I2C buses and have to be invoked as:
Code:
Wire.begin();  // first bus, pins 18 & 19
Wire1.begin(); // second bus, pins 29 & 30
Teensy LC has 2 I2C buses and have to be invoked as:
Code:
Wire.begin();  // first bus, pins 18 & 19
Wire1.begin(); // second bus, pins 22 & 23

Wire.setSDA/setSCL can only be used on Teensy 3.x & LC for selecting alternate pins [16 & 17] for the first I2C bus only.
Wire.setSDA/setSCL is not applicable for Teensy 4.x.

Are my assumptions above correct?
Is this somewhere comprehensively documented?

Thanks,
Paul
 
setSCL and setSDA only work to set the corresponding functions pin, but that pin MUST be a valid pin for that Wire buss.

On T4.x I am not sure if we have very many of them.

Wire: Pins 18 and 19
Wire1: (defaults)17, 16,
Actually there are a couple more pins here
T4 - 36(SDA) 37(SCL)
T4.1 - Code needs update Is pins 44 and 45...

Wire2: 24, 25

Now On TLC
You have: Wire SDA(18,17) SCL(19,16), Wire1: SDA(23) SCL(22)

For T3.x - It again depends on which one... They have different number of Wire objects and pins. Some details on
main PJRC page: https://www.pjrc.com/teensy/techspecs.html

Which pins shown on the different cards.
T3.2: Wire SDA(18,17) SCL(19,16) Wire1: SDA(30), SCL(29)
T3.5 Wire SDA(18,17,34, 7) SCL(19,16,33, 8), Wire1: SDA(38), SCL(37), Wire2: SDA(3), SCL(2, 27)
T3.6 Wire SDA(18,17, 34, 7) SCL(19,16, 8), Wire1: SDA(38), SCL(37), Wire2: SDA(3), SCL(2, 27), Wire3: SDA(57), SCL(56)

Note: I did not verify all of them, there are additional ones on 3.5/6...
It is easiest to look at the cards, or source code.. Example for T3.x and TLC look at WireKinetis.cpp
Code:
constexpr TwoWire::I2C_Hardware_t TwoWire::i2c0_hardware = {
	SIM_SCGC4, SIM_SCGC4_I2C0,
#if defined(__MKL26Z64__) || defined(__MK20DX128__) || defined(__MK20DX256__)
	18, 17, 255, 255, 255,
	2, 2, 0, 0, 0,
	19, 16, 255, 255, 255,
	2, 2, 0, 0, 0,
#elif defined(__MK64FX512__) || defined(__MK66FX1M0__)
	18, 17, 34, 8, 48,
	2, 2, 5, 7, 2,
	19, 16, 33, 7, 47,
	2, 2, 5, 7, 2,
#endif
	IRQ_I2C0
};
And for example: For T3.5/6 you see, for SDA: 18, 17, 34, 8, 48 and for SCL you see 19, 16 (255 signifies that there are no more pins... )
 
Awesome, thanks for the infos. I was aski g as the audioshield is using pins 18 and 19 so I cant use them for i2c
 
Quick FYI - during this I noticed that we had not pushed up changes to support the alternate Wire1 SCL and SDA pins for the new T4.1
They are in the pin ranges of the SDCard, but these are different pins on the two boards So updated the hardware table to differentiate between the T4 and T4.1

https://github.com/PaulStoffregen/Wire/pull/23

Also found my Excel document did not show these as alternate SCL/SDA in the pin card pages so those were updated as well.
 
Status
Not open for further replies.
Back
Top