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

TWI bus freeze after several thousand tx/rx cycles

I'm periodically polling a TWI sensor with a blocking call, as in

ret_code_t err_code;
m_xfer_done = false;

err_code = nrf_drv_twi_tx(&i2c, address, subAddress, 1, true);
APP_ERROR_CHECK(err_code);
while (m_xfer_done == false) {};
    
if (err_code == NRF_SUCCESS) {
        m_xfer_done = false;
        err_code = nrf_drv_twi_rx(&i2c, address, dest, count);
        APP_ERROR_CHECK(err_code);
        while (m_xfer_done == false) {};
};

This works fine about 3000 times, and then comes to grinding halt. I'm reading 8 bytes per nrf_drv_twi_rx. My first guess is running out of memory, but why? I'm just sampling the bus and updating the values of a static unit8_t dest[8].

Parents
  • I have no idea why this helps, but all problems vanish when I enable the softdevice. It's weird, since I'm not actually using the softdevice, but all I've done is

    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    softdevice_app_ram_start_get(&ram_start);
    softdevice_enable(&ram_start);
    

    and now things are rock-solid. 28,000 data collection and FLASH-write cycles and still going strong....

Reply
  • I have no idea why this helps, but all problems vanish when I enable the softdevice. It's weird, since I'm not actually using the softdevice, but all I've done is

    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    softdevice_app_ram_start_get(&ram_start);
    softdevice_enable(&ram_start);
    

    and now things are rock-solid. 28,000 data collection and FLASH-write cycles and still going strong....

Children
No Data
Related