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,

    Initially I used 'twi_scanner' and got the address of the slave device. But to debug for NACK, I kept debug print for else condition.

        for (address = 1; address <= TWI_ADDRESSES; address++)
        {
            err_code = nrf_drv_twi_rx(&m_twi, address, &sample_data, sizeof(sample_data));
            if (err_code == NRF_SUCCESS)
            {
                detected_device = true;
                NRF_LOG_INFO("TWI device detected at address 0x%x.", address);
            }
            else
            {
                NRF_LOG_INFO("error %d", err_code);
            }
            NRF_LOG_FLUSH();
        }

    I am getting 33281. I am not sure what is this.

    <info> app: error 33281
    <info> app: error 33281
    <info> app: TWI device detected at address 0x40.
    <info> app: error 33281
    <info> app: error 33281
    <info> app: error 33281
    <info> app: error 33281

    Then to crosscheck I loaded 'twi_sensor'. Since there is no device with slave address 0x90, I expected NRF_DRV_TWI_EVT_ADDRESS_NACK or NRF_DRV_TWI_EVT_DATA_NACK as part of twi_handler(). But none occurred.

    The reason behind all these is to understand when NACK will trigger and once triggered how to handle.

    Thanks & Regards

    Vishnu Beema

Reply
  • Hello,

    Initially I used 'twi_scanner' and got the address of the slave device. But to debug for NACK, I kept debug print for else condition.

        for (address = 1; address <= TWI_ADDRESSES; address++)
        {
            err_code = nrf_drv_twi_rx(&m_twi, address, &sample_data, sizeof(sample_data));
            if (err_code == NRF_SUCCESS)
            {
                detected_device = true;
                NRF_LOG_INFO("TWI device detected at address 0x%x.", address);
            }
            else
            {
                NRF_LOG_INFO("error %d", err_code);
            }
            NRF_LOG_FLUSH();
        }

    I am getting 33281. I am not sure what is this.

    <info> app: error 33281
    <info> app: error 33281
    <info> app: TWI device detected at address 0x40.
    <info> app: error 33281
    <info> app: error 33281
    <info> app: error 33281
    <info> app: error 33281

    Then to crosscheck I loaded 'twi_sensor'. Since there is no device with slave address 0x90, I expected NRF_DRV_TWI_EVT_ADDRESS_NACK or NRF_DRV_TWI_EVT_DATA_NACK as part of twi_handler(). But none occurred.

    The reason behind all these is to understand when NACK will trigger and once triggered how to handle.

    Thanks & Regards

    Vishnu Beema

Children
No Data
Related