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

twi_handler doent work after wake up

Hi everybody,

I'm developing an product with :

NRF52840, V0.9.0, SDK15

In the DK I connected LIS3DH (accelerometer by TWI)

all works.I configuration of HZ and temperature.

even I can read the sensor. (the twi_handler works fine)

but I included a code of NFC wake up (power on, sleep)

and when the NFC wake up the MCU, I what to read again the accelerometer.

in this moment the TWI RX or TX doesnt call the twi_handler. and the program stuck in    while (m_xfer_done == false);

I have tested disable Twi before to WFE, and enable it when wake up,...  but it doesnt work..

Could you give me some ideas about what happen?

thanks 

Ricardo

void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
  switch (p_event->type)
    {
        case NRF_DRV_TWI_EVT_DONE:       
            if (p_event->xfer_desc.type == NRF_DRV_TWI_XFER_RX)
            {
                data_handler(m_sample);
            }
            m_xfer_done = true;
             break;
        default:
            break;
    }
}

static void read_sensor_Vibrometer()          //                                      *********************** LECTURA DE SENSOR VIBRACION *********************
{
    ret_code_t err_code;
    m_xfer_done = false; 

    //  ****** send a request accelerometer values ****
    
    uint8_t reg[1] = {LIS3DH_GET_ACC};
    err_code = nrf_drv_twi_tx(&m_twi, LIS3DH_WRITE, reg, sizeof(reg), false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);
    m_xfer_done = false; 
    
  
     //  ****** read the values ****
    
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_twi_rx(&m_twi, LIS3DH_READ, recepcion, 6);    //  ret_code_t err_code;
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);
    m_xfer_done = false; 

}

Related