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

nrf52 TWI error code

Hi,

I am trying to write a I2C read and write wrappers for Invensense MPU9250. Previously, I was using SDK11 and I don't have any issue with it. However, after porting the code into the new SDK nRF5_SDK_12.2.0_f012efa, i kept getting errors. However, the error did not surface immediately, it's after a short period of continuous reading then it surfaces. I have tried 2 type of TWI approaches.

  1. Using APP_TWI, I will get an internal error (code 3). Since I don't really need to use the scheduler, I tried to use the twi driver directly.
  2. Using the TWI driver, I get an error code of (0x00008201) which I am unsure on how to even decipher it. Hopefully, someone can help me to unravel this issue.

best regards

Parents
  • Hi,

    below attached is the code. The error occured after nrf_drv_twi_rx.

    ret_code_t ret;
    
    	do
    {
       uint8_t addr8 = (uint8_t)reg_addr;
       ret = nrf_drv_twi_tx(&m_twi_master, slave_addr, &addr8, 1, true);
       if (NRF_SUCCESS != ret)
       {
           break;
       }
       ret = nrf_drv_twi_rx(&m_twi_master, slave_addr, (uint8_t*)data_ptr, len);
    }while (0);
    	
    	APP_ERROR_CHECK(ret);
    	
    return ret; //this is catered for MPU9250 API
    
Reply
  • Hi,

    below attached is the code. The error occured after nrf_drv_twi_rx.

    ret_code_t ret;
    
    	do
    {
       uint8_t addr8 = (uint8_t)reg_addr;
       ret = nrf_drv_twi_tx(&m_twi_master, slave_addr, &addr8, 1, true);
       if (NRF_SUCCESS != ret)
       {
           break;
       }
       ret = nrf_drv_twi_rx(&m_twi_master, slave_addr, (uint8_t*)data_ptr, len);
    }while (0);
    	
    	APP_ERROR_CHECK(ret);
    	
    return ret; //this is catered for MPU9250 API
    
Children
No Data
Related