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

I2C communication error

Hello, support team.

In my test board, lis3mdl chip is connected to nordic chip via I2C.

During initializing board, device ID of lis3mdl is checked.

Most of time it works fine. And sensor data is read correctly.

But time to time, I can't get device ID from lis3mdl.

After several times of power reset, It works again.

I don't have any idea for this phenomenon.

Could you suggest me any clue?

Parents
  • Hi,

    Have you checked that the lis3mdl device is powered correctly when this issue occurs?

    Can you provide a logic trace of the TWI bus when you are not able to read the sensor correctly?

    Best regards,
    Jørgen

  • Hello,

    I2C clock signal is checked with oscilloscope.

    When normal operation, clock signal is occurs cyclically.

    But when error occurs, there is no clock signal.

    - CLK when normal operation

    - CLK when error occurs

    In my source code, I made it to re-try to read sensor ID if response is incorrect.

    Should I do something else like reset sensor or reset I2C bus?

        /* read sensor id via I2C */
        lis3mdl_device_id_get(&lis_ctx, &whoamI);
        
        /* If incorrectly work, re-try */
        while (whoamI != LIS3MDL_ID)
        {   
            nrf_delay_ms(50);
            lis3mdl_device_id_get(&lis_ctx, &whoamI);
        }

    And error_code 3 is returned from nrf_drv_twi_xfer function.

    I can't debug deeper.

Reply
  • Hello,

    I2C clock signal is checked with oscilloscope.

    When normal operation, clock signal is occurs cyclically.

    But when error occurs, there is no clock signal.

    - CLK when normal operation

    - CLK when error occurs

    In my source code, I made it to re-try to read sensor ID if response is incorrect.

    Should I do something else like reset sensor or reset I2C bus?

        /* read sensor id via I2C */
        lis3mdl_device_id_get(&lis_ctx, &whoamI);
        
        /* If incorrectly work, re-try */
        while (whoamI != LIS3MDL_ID)
        {   
            nrf_delay_ms(50);
            lis3mdl_device_id_get(&lis_ctx, &whoamI);
        }

    And error_code 3 is returned from nrf_drv_twi_xfer function.

    I can't debug deeper.

Children
No Data
Related