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

Conversion from NRFX_TWI to NRFX_TWIM

HI,

I am working on the interface between the nrf52832 and the MPU9250 IMU.

I have communication working fine with using nrfx_twi, but I have the following error when I try to use  nrfx_twim :

<error> app: ASSERTION FAILED at /Users/slareau/nrf52_development/nRF5_SDK_16/modules/nrfx/drivers/src/nrfx_twim.c:561

I can get WHOIAM working indicating that the communication between the NRF52 and the IMU is working.

The error occur when I call the IMU self-test.

Looking nrfx_twim.c line 561 is :  p_xfer_desc->secondary_length))    from the following code:

nrfx_err_t nrfx_twim_xfer(nrfx_twim_t           const * p_instance,
                          nrfx_twim_xfer_desc_t const * p_xfer_desc,
                          uint32_t                      flags)
{
    NRFX_ASSERT(TWIM_LENGTH_VALIDATE(p_instance->drv_inst_idx,
                                     p_xfer_desc->primary_length,
                                     p_xfer_desc->secondary_length));

    nrfx_err_t err_code = NRFX_SUCCESS;

 I have include the init / read / write driver below.  Those came from an old exemple (SDK12)  that I have modernize as I could - I don't have a lot of experience and nrfx TWI and TWIM exemple are rare...  As I mention, the nrfx_twi version work fine (except for a compass calibration issue - might be related to communication issue or not).

To create the TWIM version, i have juste replace TWI by TWIM in appropriate place, and change the SDK_config setting.

How can I fix this ? Your help is always greatly appreciate.

Regards,

<error> app: ASSERTION FAILED at /Users/slareau/nrf52_development/nRF5_SDK_16/modules/nrfx/drivers/src/nrfx_twim.c:561