Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Teensy 4.0 i2c pull-up resistors

  1. #1
    Junior Member
    Join Date
    Aug 2019

    Teensy 4.0 i2c pull-up resistors

    Hi, I'm just checking if Teensy 4.0 requires i2c pull-ups similar to 3.6?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Yes, external pullups need to be present for use

  3. #3
    You can do before Wire.begin();

    pinMode(16, INPUT_PULLUP);
    pinMode(17, INPUT_PULLUP);
    pinMode(18, INPUT_PULLUP);
    pinMode(19, INPUT_PULLUP);
    pinMode(24, INPUT_PULLUP);
    pinMode(25, INPUT_PULLUP);

  4. #4

    had the same question..also for CS signals for SPI...or digitalRead switches switching to ground....are there external pullup resistor needed or will the INPUT_PULLUP in the pinMode method do it for you?

    Thank you


  5. #5
    Senior Member
    Join Date
    Apr 2020
    Pullup resistors should be used on i2c. For other pins, think about what signals are driven by the teensy and what they do. If a teensy pin is used as an output, most likely you'll find it needs a pull down resistor of about 10K. Why? because before it's configured all those pins, they are floating and your widget could send out all sorts of garbage. Inputs are ignored, but anything driving another pin should be properly conditioned.

  6. #6
    Okay....then the question other way round....

    What is the INPUT_PULLUP parameter exactly doing in the teensy...(internal wiring a pullup resistor) ? Is this only for inputs ?

    Thank you


  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quote Originally Posted by Spyy View Post
    What is the INPUT_PULLUP parameter exactly doing in the teensy...(internal wiring a pullup resistor) ?
    Yes, exactly. Inside the chip, every pin has built-in pullup and pulldown resistors. Or it very well may be transistor-based circuitry which acts like a resistor. But whatever technique NXP used inside the chip, it can be turned on or disconnected under software control.

    To try to specifically answer all your questions...

    Pullup or pulldown resistors only make sense when the pin is not configured as a normal output.

    For I2C, the internal pullup resistors are activated on Teensy 4.0. That is different than Teensy 3.x, where they are not used. The internal pullup resistors are much weaker than the recommended range (1K to 4.7K) for I2C, so it's not a good practice to use only the internal pullups. But unlike Teensy 3.x where I2C will not work at all (why NXP designed those chips to not allow the internal pullups in I2C mode is a mind boggling mystery), on Teensy 4.x the pins can and do by default (using the Wire lib) have their weak pullups active, so you can usually get a 100 kbit/sec I2C chip to work without adding resistors.

    You asked "Is this only for inputs". Generally yes. But I said "when the pin is not configured as a normal output", because there are also some non-input cases where pullup resistors make sense.

    For SPI CS signals, especially for companies making modules, a real pullup resistor is good design practice. Suppose to build a project using a SD card and a Wiznet Ethernet, both connected to SPI. You'll use the SD library and Ethernet library. The problem is the condition of the CS signals before you run either library. On Teensy 3.x the pins default to INPUT_DISABLE mode, meaning they are completely undriven in any way and could "float" to pretty much any random voltage. On Teensy 4.x the pin default to "keeper" mode, meaning they could be like a weak pulldown (most likely) or a weak pullup (less likely). Either way, the point is the voltage on both CS signals is unknown. Either or both could happen to be at a logic low level, meaning the chip is selected.

    The main SPI CS problem happens when you do something like Ethernet.begin() before SD.begin(), but the SD card's unknown CS signal happens to not have enough voltage to be at logic high (unselected). While the Ethernet library does lots of SPI communication to the Wiznet chip, the SD card will also "hear" all that communication because its CS pin hasn't been configured and very likely may be at a random voltage which the card sees at logic low.

    So the purpose of real physical pullup resistors on those CS signals is to keep each SPI chip deselected until you run the library code to configure it. This really only matters when you connect 2 or more such chips. It also usually only matters if you use separate libraries and don't add code which drives both CS pins high before you use either of them.

    There are other non-input uses of pullup resistors. The other big one is when the pins are used in a mode called "open collector" or sometimes "open drain". In this mode, the chip works normally when you use digitalWrite LOW. But when you use digitalWrite HIGH, the pin doesn't actually drive the signal high. It effectively disconnects. You need a pullup resistor to cause the signal to go high. Normally the weak pullup resistors inside the chip aren't fast enough. But this usage isn't very common and what speeds are actually needed depend greatly on the details of those not-very-common uses.

    Normally pullup resistor and the INPUT_PULLUP mode are used for inputs, where you have something like a pushbutton or relay contact (or another chip using open collector mode) which connects the pin to GND. It's just a mechanical switch. When the switch is not connecting the pin to GND, the pullup resistor is needed so the pin returns to logic high.

    Pullup resistors also commonly used on inputs where the signal might come disconnected or physically unplugged.

    So while pullup resistors have other uses the only inputs, by far the most common usage is input signals.

    Hopefully that answered all your questions?

  8. #8
    Senior Member
    Join Date
    Jul 2020
    Quote Originally Posted by PaulStoffregen View Post
    Yes, exactly. Inside the chip, every pin has built-in pullup and pulldown resistors. Or it very well may be transistor-based circuitry which acts like a resistor.
    Its almost always be a FET with an approriate channel geometry to get roughly the resistance quoted - in VLSI an actual resistor of high
    value would be more expensive in chip area than a FET channel (you'd need a long serpentine layout - the resistance per-square of a FET channel is already in the k ohm range, whereas for other semiconductor layers it tends to be much lower).

    Thus the internal pullups and pulldown's are usually non-linear, and very wide tolerance in actual value, neither of which matters for
    a logic pullup/down. When you do need proper resistors on chip that are linear and higher tolerance you'd resort to other methods, I
    found this nice article:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts