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

TWI not responding to ack

Hi, 

I have some trouble using TWI : the slave device connected to nrf52 sends an ack signal (seen on scope) but the i2c handler raises an incorrect address error and discards the ongoing i2c transmission.

p_event->type in the following function is 1.

void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
switch (p_event->type)
{
case NRF_DRV_TWI_EVT_DONE:
if (p_event->xfer_desc.type == NRF_DRV_TWI_XFER_RX)
{
//data_handler(m_sample);
}
i2c_xfer_done = true;
break;
default:
break;
}
}

softdevice is 15.2.

the init function is


#define TWI_INSTANCE_ID 1
static const nrf_drv_twi_t m_twi_master = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
void initI2C()
{
ret_code_t ret;
const nrf_drv_twi_config_t config = {
.scl = PIN_SCL,
.sda = PIN_SDA,
.frequency = NRF_TWI_FREQ_400K,
.interrupt_priority = APP_IRQ_PRIORITY_LOW,
.clear_bus_init = false
};

*(uint32_t *)(0x40003000 + 0xFFC ) = 0;
*(uint32_t *)(0x40003000 + 0xFFC ) = 1;
//*(uint32_t *)(0x40003000 + 0xFFC ) = 1;
do {

nrf_gpio_cfg_input (PIN_SCL,NRF_GPIO_PIN_PULLUP );
nrf_gpio_cfg_input (PIN_SDA,NRF_GPIO_PIN_PULLUP );
ret = nrf_drv_twi_init(&m_twi_master, &config, twi_handler,NULL);
if(NRF_SUCCESS != ret)
break;

nrf_drv_twi_enable(&m_twi_master);
}while(0);
i2c_xfer_done = true;
}

Related