sandeepmistry / arduino-nRF5

Arduino Core for Nordic Semiconductor nRF5 based boards
Other
873 stars 278 forks source link

TwoWire::begin pin configuration incorrect with alternate pins #460

Open evaninventhys opened 3 years ago

evaninventhys commented 3 years ago

Hours of troubleshooting (checking pins, changing pull-up values, changing pins, etc) - I believe I discovered a bug in TwoWire - the pins are not configured as open-drain high current.

I've used TwoWire::setPins(uint8_t pinSDA, uint8_t pinSCL)

to set SDA/SCL to alternate pins (not tested with original pins)

My configuration is VDD=3.3V, 2.2K pull-up (also tried 10k, 4.7k) on SDA/SCL, wire length ~10cm. I2C is communicating between two Adafruit NRF52 feather (/product/3406) - one as "master/scanner", one as "responder" with address of 0x1

In the methods:

TwoWire::begin(void) TwoWire::begin(uint8_t address)

The (incorrect) pin configuration is GPIO_PIN_CNF_DRIVE_S0S1, meaning "Standard Drive Sink"

The correct pin configuration should be GPIO_PIN_CNF_DRIVE_H0D1, meaning "High Drain Sink"

I could never get the two feathers to communicate between them with a 10k, 4.7K or 2.2K pull-up to 3.3V.

However, it worked after I found and changed the above pin configuration directly in the Library code found here: %AppData%\Local\Arduino15\packages\adafruit\hardware\nrf52\0.21.0\libraries\Wire

image