The twi master driver BNO085 obtains invalid data for a period of time

TWI Master drives BNO085 to read four-element data at intervals of 20ms, and I2C will not be able to read data when the device works for more than 10 minutes. INITTWI and reinitializing BNO085 still can't get the correct data, only resetting NRF52832 can continue to run normally, is there any way to solve the problem of probabilistic inability to get data, or how to make it continue to work by reinitializing TWIs, thank you
and blow is the code Reinit the twi drvier

twi_unint();
nrf_delay_ms(100);
hal_bno085_init();



void hal_bno085_init(void)
{

twi_init();
imu_gpio_init();
softReset();
NRF_LOG_INFO("soft reset end");
NRF_LOG_FLUSH();
sensor_check();
NRF_LOG_INFO("sensor check");
NRF_LOG_FLUSH();


enableRotationVector(SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR,20);
enableRotationVector(SENSOR_REPORTID_LINEAR_ACCELERATION,50);
}

  • addition some code below:

    void twi_init (void)
    {
        ret_code_t err_code;
    
        const nrf_drv_twi_config_t twi_bno085_config = {
           .scl                = ARDUINO_SCL_PIN,
           .sda                = ARDUINO_SDA_PIN,
           .frequency          = NRF_DRV_TWI_FREQ_400K,
           .interrupt_priority = APP_IRQ_PRIORITY_MID,
           .clear_bus_init     = false
        };
    
        err_code = nrf_drv_twi_init(&m_twi, &twi_bno085_config, twi_handler, NULL);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_twi_enable(&m_twi);
    }
    
    extern void nrf_drv_twi_uinit(nrf_drv_twi_t const *        p_instance);
    void twi_unint(void)
    {
    	nrf_drv_twi_disable(&m_twi);
    	nrf_drv_twi_uinit(&m_twi);
    }

  • Hi,

    Can you elaborate on what happens when the device stops working? Do you get incorrect data, no data at all, any error codes from function calls, etc?

    Have you checked the I2C/TWI bus with a logic analyzer, to see if the commands are sent and received correctly?

    nrf_drv_twi_uinit() is not a function in the SDK, have you implemented this yourself? What does it do? Why is this declared as extern?

    The correct function to use should be "nrf_drv_twi_uninit()".

    Best regard,
    Jørgen

  • The device will continuously read the data of bno085 through i2c and send it out wirelessly through esb. There is no fixed situation when this problem occurs. Some devices may take more than 10 minutes, while others may take an hour or even longer. The interface I call is as follows

Related