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

NRF_ERROR_BUSY for I2C read inside an RTOS thread

In the task, when I do a TWI read via nrf_drv_twi_rx(), in the second iteration of the thread, the driver function returns NRF_ERROR_BUSY.

Is it that the driver takes longer than how fast the thread runs thus initiating a second read even though the previous read transfer wasn't even done?

I'm basing it off the frequencies: Tick ISR runs at 1ms, and an I2C read takes ~5 read cycles (WRITE, ACK, READ, DATA#1, DATA#2) assuming i'm reading two bytes.


Following is a snippet:

void SystemTask::mainThread()
{       
    while(true)
    {
        A.xferData();
A.read();
}
}
uint16_t A::read()
{
     m_xfer_done = false;
    ret_code_t err_code = nrf_drv_twi_rx(&m_twi, ADDR, _buffer, 2);

    APP_ERROR_CHECK(err_code);   // errors out here!

    while(!m_xfer_done);

    return _value;	         
}
Parents Reply Children
No Data
Related