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

TWI communication between two nrf52 device

Hi,

I am trying to extablish TWI communication between 2 nRF52832 devices. One should be master and other slave.

For TWI initialization in nRF52 master, I have below source code:

void twi_init(void)
{

ret_code_t err;

const nrf_drv_twi_config_t twi_config = {
.scl = 25,
.sda = 18,
.frequency = NRF_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH,
.clear_bus_init = false
};

err = nrf_drv_twi_init(&m_twi, &twi_config, NULL, NULL);
APP_ERROR_CHECK(err);

nrf_drv_twi_enable(&m_twi);

}

For TWI initialization in nRF52 slave, I have below source code:

void twi_slave_init(void)
{
ret_code_t err;

const nrf_drv_twis_config_t slave_twi_config = {
.addr = {0x44, 0},
.scl = 25,
.scl_pull = NRF_GPIO_PIN_PULLUP,
.sda = 18,
.sda_pull = NRF_GPIO_PIN_PULLUP,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH
};

err = nrf_drv_twis_init(&slave_twi, &slave_twi_config, NULL);
APP_ERROR_CHECK(err);

nrf_drv_twis_enable(&slave_twi);

}

I try to run twi_scanner in nrf52 master, but could not find nrf52 slave device.

Do I need to pullup I2C address pins also in nRF52 slave device?

Can you suggest if above way is correct?

Related