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

When EVENTS_ERROR become True ?

Hi. I have troubles. I'm using nRF52 DK and V0.9.0. I'm making program that does TWI communication between MPU9250 what is 9-axis sensor. error is false every time. When it become True? Please help me!

static bool twi_action_wait(nrf_drv_twi_t const * const p_instance)
{
    bool     *error*;
    bool     done;
    uint32_t timeout = 0;
    volatile transfer_t * p_transfer = &(m_cb[p_instance->instance_id].transfer);

    do
    {
        done  = nrf_twi_event_check(p_instance->p_reg, p_transfer->end_event);
        *error* = nrf_twi_event_check(p_instance->p_reg, NRF_TWI_EVENTS_ERROR);
        *error* |= (++timeout < BUSY_LOOP_TIMEOUT) ? false : true;
    } while (!(*error* | done));
    return !*error*;
}

//Question Update at 2/29. It's my program.******************** TWI_main.c

//Question Update at 3/8. It's MPU9150 program.******************** main.c

Parents
  • Description of twi_action_wait():

     * @brief Function for blocking the module until desired event occurs.
     * @param[in] p_instance      TWI.
     * @return    False if any error has occurred.
    

    Description for nrf_twi_event_check():

     * @brief Function for returning the state of a specific event.
     * [...]
     * @retval true   If the event is set.
     * @retval false  If the event is not set.
    

    It is not easy to say what is going on without the rest of your code, but my guess is that you call twi_action_wait() between some TWI transfers to you sensor(?). This is a blocking function and will stay in the while() loop until the expected event is returned. This means that if something goes wrong in your transfers your code gets blocked. Typical things that can go wrong is:

    1. The sensor is not connected to the correct pins.
    2. The sensor is not initiated or powered on and hence won't respond.
    3. You are using the wrong TWI address and hence the sensor won't respond.

    Anyway, I would recommend that you update to SDK V11 which has a much more developed TWI driver. At the very least use SDK V0.9.2.

  • Thank you! I will read it and practice use the sensor. Best Regards.

Reply Children
No Data
Related