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

Why there is no TWI NACK for wrong Slave address

Hello,

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image.

To understand TWI better, I loaded 'twi_sensor' example as is on nRF52832 development kit where there is no LM75B sensor.

As per below link, if there is a wrong slave address, there will be NACK.

https://blog.digilentinc.com/i2c-how-does-it-work/

But I did not receive any interrupt in twi_handler() of event type NRF_DRV_TWI_EVT_ADDRESS_NACK or NRF_DRV_TWI_EVT_DATA_NACK. When will these occur actually.

Because of this, code struck in while loop "while (m_xfer_done == false);"

Thanks & Regards

Vishnu Beema

Parents
  • Hello,

    I got the root cause. I added debug print under 'default' case. For wrong address I am getting NRF_DRV_TWI_EVT_ADDRESS_NACK. But this is not printing on terminal because of "while (m_xfer_done == false);"

    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:
             NRF_LOG_INFO("twi_default %d", p_event->type);
                break;
        }
    }

    Thanks & Regards

    Vishnu Beema

Reply
  • Hello,

    I got the root cause. I added debug print under 'default' case. For wrong address I am getting NRF_DRV_TWI_EVT_ADDRESS_NACK. But this is not printing on terminal because of "while (m_xfer_done == false);"

    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:
             NRF_LOG_INFO("twi_default %d", p_event->type);
                break;
        }
    }

    Thanks & Regards

    Vishnu Beema

Children
No Data
Related