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

how to set default I2C pin(SDA AND SCL) for nrf52832 using UICR customer register?

How to set  SDA= p0.25;and SCL=P0.26 default pin configration.

Parents Reply
  • If you are using the TWI driver in the SDK (nrf_drv_twi), the GPIO pin numbers are set in the config struct passed to nrf_drv_twi_init(). For instance, in the twi_sensor example, the ARDUINO_SCL/SDA pins are used:

    void twi_init (void)
    {
        ret_code_t err_code;
    
        const nrf_drv_twi_config_t twi_lm75b_config = {
           .scl                = ARDUINO_SCL_PIN,
           .sda                = ARDUINO_SDA_PIN,
           .frequency          = NRF_DRV_TWI_FREQ_100K,
           .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
           .clear_bus_init     = false
        };
    
        err_code = nrf_drv_twi_init(&m_twi, &twi_lm75b_config, twi_handler, NULL);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_twi_enable(&m_twi);
    }

    These pins are defined in the pca10040.h board header file:

    #define ARDUINO_SCL_PIN             27    // SCL signal pin
    #define ARDUINO_SDA_PIN             26    // SDA signal pin

    You can define your own pins in the application:

    #define TWI_SCL_PIN             26    // SCL signal pin
    #define TWI_SDA_PIN             25    // SDA signal pin

    And then set these in the config struct.

Children
Related