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

nrf_drv_twi doesnt read multiple bytes in SDK 12.2

I am trying to use the function or any function with my BLE UART application. I have a timer that expires to kickoff reading of some sensors and then when I try to read my sensor it only writes the address and data register then reads the the device address and stops at one byte regardless of what argument I place in length to receive. The even wierder thing is in a stnadalone non softdevice application I test my I2C devices and it reads all 3 data bytes if I place a breakpoint before the read here is my code snippet.

static void read_sensor_data()

	ret_code_t err_code = 0;
	m_xfer_done = false;
	uint8_t m_txbuf = LM75B_REG_TEMP;
	uint8_t m_sample = 0;

	nrf_drv_twi_tx(&m_twi, LM75B_ADDR, &m_txbuf, 1, false);
	while (m_xfer_done == false);

	m_xfer_done = false;
/* Read 1 byte from the specified address - skip 3 bits dedicated for fractional part of temperature. */
ret_code_t err_code = nrf_drv_twi_rx(&m_twi, LM75B_ADDR, &m_sample, 3);
	while (!m_xfer_done);
Parents Reply
  • Sure thing....thanks so much I have to finish this today and it makes no sense....I do see the event occuring however my software hangs when polling m_xfer_done on RX not on TX it seems to work there....

    void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context) { uint8_t err_code = 0;

    switch (p_event->type)
    {
    case NRF_DRV_TWI_EVT_DONE:
            if (p_event->xfer_desc.type == NRF_DRV_TWI_XFER_RX)
            {
    							err_code = 0;
    							err_code = 0;
    							err_code = 0;
    							//counts += 1;
    							twi_rx_done = true;							
            }
      }
      m_xfer_done = true;
    

    }

Children
No Data
Related