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

how can i do i2c initialization on any gpio pin ?

Hello all,

I am right now working on one project. where i use nrf52832 BLE board. right i am doing i2c communication of temperature sensor(lm6bd) with ble board. but can you please tell me how can i use any gpio pin as i2c (SDA and SCL ) pins ? i am trying to do same using pin P0.06(SDA) and P0.07(SCL). so is this possible that i can read data of temperature sensor from pin which i mention.

I have read data for same at pin P0.27(SCL) and P0.26(SDA). and i successfully got result and i want get same data from different pin. because my project has requirement to use i2c at a different pin.

So please guide me how can i do? what should i need to change in program for configuration i2c at gpio pin.

Thanking you,

Urvisha Andani 

Parents
  • I have read data for same at pin P0.27(SCL) and P0.26(SDA). and i successfully got result and i want get same data from different pin.

    So have you looked at how that code defines the pins to use?

    Change them to the pins you want!

  • In my code i config as like this type:

    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
    };

    ARDUINO SCL PIN and AROUND SDA PIN this pin is define in inbuilt library (pca10040.h) like this:

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

    I try to define same as below and change pin from 27 to 7 and 26 to 6. and then built program but problem at generation of event like. NRF_DRV_TWI_EVT_DONE: this event is not generate 

Reply
  • In my code i config as like this type:

    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
    };

    ARDUINO SCL PIN and AROUND SDA PIN this pin is define in inbuilt library (pca10040.h) like this:

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

    I try to define same as below and change pin from 27 to 7 and 26 to 6. and then built program but problem at generation of event like. NRF_DRV_TWI_EVT_DONE: this event is not generate 

Children
Related