Teensy 4 option for 100 kohm or 47 kohm pull-up setting instead of 22 kohm default

ericfont

Well-known member
According to the 1062 programming manual, digital inputs can use either 22k, 47k, or 100k internal pull-up resistors:

teensy-pullupdown-values.png

According to https://github.com/PaulStoffregen/c...42c55a2278c6cd72b/teensy4/digital.c#L148-L156 the actual setting used for pinMode(pin#, INPUT_PULLUP) is 22 kohm pull-up (IOMUXC_PAD_PUS(3), and I've verified this experimentally).

It would be nice if there was extra #defines (after the line defining INPUT_PULLUP https://github.com/PaulStoffregen/c...3f1cbcc2b325fa59b886fa/teensy/core_pins.h#L29) for the other modes, such as INPUT_PULLUP_47K, INPUT_PULLUP_100K, and then also have INPUT_PULLUP_22K which is the same as the default INPUT_PULLUP.

I found that I can simply copy that entire pinMode function into my teensy program and modify it to use IOMUXC_PAD_PUS(2) for 100k pull-up or IOMUXC_PAD_PUS(1) for 47k pull-up, like so:

Code:
void pinMode_INPUT_PULLUP_100K(uint8_t pin)
{
  const struct digital_pin_bitband_and_config_table_struct *p;

  if (pin >= CORE_NUM_DIGITAL) return;
  p = digital_pin_to_info_PGM + pin;
  *(p->reg + 1) &= ~(p->mask); // TODO: atomic
  *(p->pad) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(2) | IOMUXC_PAD_HYS;
  *(p->mux) = 5 | 0x10;
}

void pinMode_INPUT_PULLUP_47K(uint8_t pin)
{
  const struct digital_pin_bitband_and_config_table_struct *p;

  if (pin >= CORE_NUM_DIGITAL) return;
  p = digital_pin_to_info_PGM + pin;
  *(p->reg + 1) &= ~(p->mask); // TODO: atomic
  *(p->pad) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(1) | IOMUXC_PAD_HYS;
  *(p->mux) = 5 | 0x10;
}

and then I can simply call my custom function. But the reason I bring this up is I think it would be more useful for everyone to modify those github files to have those extra #defines to select between these 3 different pullup modes. But I can also understand just wanting to keep it simple by supporting only one pull up define.
 
Hi, Just wanted to give this subject a bump.
Was reading through the 1062 pdf today and I noticed the optional Pull-Up resistor values. 22K (default), 47K, and 100K.
Extra defines would be handy.

The higher values could be useful when fine tuning the FastTouch Capitative touch sensing library.
Perhaps also in extreme power saving efforts.
 
Adding all available Pullup resistors to Teensduino

As I needed other values as pullup resistors, I added in core_pins.h:
(directory: ...\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.1\cores\teensy4)

#define INPUT_PULLUP47k 6
#define INPUT_PULLUP100k 7

and in digital.c at line 152:
} else if (mode == INPUT_PULLUP47k) {
*(p->pad) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(1) | IOMUXC_PAD_HYS;
} else if (mode == INPUT_PULLUP100k) {
*(p->pad) = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE | IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(2) | IOMUXC_PAD_HYS;

would be nice, if this or something similar, would be added to future versions of Teensduino.

Best regards

Edmund
 
Back
Top