I2C: disabling internal pullups?

jmarsh

Well-known member
On a typical arduino board (e.g. atmega 328p) the following code will initialize I2C then disable the internal pullup resistors:
C:
Wire.begin();
digitalWrite(SDA, LOW);
digitalWrite(SCL, LOW);
But on a T4.x, this doesn't work because using digitalWrite(x, LOW) activates the pulldown resistors. This behaviour doesn't seem to be mentioned anywhere in the arduino documentation and makes code incompatible between platforms.
Unless there's some precedent I'm unaware of, I think for compatibility purposes activating the pulldowns should only be possible using pinMode(x, INPUT_PULLDOWN) and calling digitalWrite(x, LOW) on a pin that was previously set to INPUT mode should turn off the pullup. Additionally, the pullup/down pad fields are the only things that should be modified e.g. not the drive strength or open-drain configuration.
 
Last edited:
Back
Top