This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use internal nRF52 pull-up w/ TWIM?

Hi all --

I have a tricky layout "issue" where unfortunately, I've ended up connecting my I2C device to the BlueTooth module on the side of the module where my VDD isn't routed (two-layer board + a solid GND plane on the bottom layer == tricky layout / using 0R resistors to jump traces...).

I have a set of 10K PU in my schematic right now to VDD -- on some parts I've used in the past, the PU/PD functionality of a given pin is tied to the GPIO 'peripheral' usage -- i.e., if that pin is given to a SPI/I2C or other peripheral, the pull-up / pull-down control is lost.

I expect that the internal PU is slightly weaker than 10k, but I only have a single I2C device on the board. Can I configure a pin to have the internal pull-up on in addition to being the TWIM SCL and SDA pins?

  • Hi Krunal,

    the internal pull-ups are enabled by default by the TWI Driver(nrf_drv_twi.c). If you take a look at the nrf_drv_twi_init(...) function you'll see that the GPIO pins are configured the following way

    NRF_GPIO->PIN_CNF[p_config->scl] = SCL_PIN_INIT_CONF;
    NRF_GPIO->PIN_CNF[p_config->sda] = SDA_PIN_INIT_CONF;
    

    where SCL_PIN_INIT_CONF and SDA_PIN_INIT_CONF are defined as

    #define SCL_PIN_INIT_CONF     ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
                                  | (GPIO_PIN_CNF_DRIVE_S0D1     << GPIO_PIN_CNF_DRIVE_Pos) \
                                  | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)  \
                                  | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos) \
                                  | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos))
    #define SDA_PIN_INIT_CONF        SCL_PIN_INIT_CONF
    

    Best regards

    Bjørn

  • Perfect, thanks! I may add a high-value pull-down to both lines to enforce some kind of state before the nRF52 comes up and asserts state on its pins.

Related