I am using TWI0 for MCP9808 and I notice that a single Write operation causes two Writes (one without a stop condition while the 2nd one with a stop condition)
void handler(nrf_drv_twi_evt_t const * p_event, void * p_context) { Sensor* sensor = static_cast<Sensor*>(p_context); switch (p_event->type) { case NRF_DRV_TWI_EVT_DONE: if (p_event->xfer_desc.type == NRF_DRV_TWI_XFER_TX) { m_xfer_done = true; } break; default: break; } } void Sensor::Write(uint8_t reg, uint8_t size) { ret_code_t error_code = nrf_drv_twi_tx(&m_twi, SENSOR_ADDR, ®, size, false); APP_ERROR_CHECK(error_code); while(!m_xfer_done); // set by the ISR } void Sensor::Start() { i2cConfig = { .scl = TWI_SCLK, .sda = TWI_SDA, .frequency = static_cast<nrf_drv_twi_frequency_t> (TWI_FREQ), .interrupt_priority = TWI_IRQ_PRIORITY, .clear_bus_init = false }; ret_code_t err_code = nrf_drv_twi_init(&m_twi, &mI2cConfig, handler, this); APP_ERROR_CHECK(err_code); nrf_drv_twi_enable(&m_twi); Write(0x5, 1); // send the register address that we'd be interfacing with } // main.cpp Sensor sensor; int main() { sensor.Start(); while(1); }