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

TWI (also called IIC, I2C) is reporting the error NRFX_TWI_EVT_BUS_ERROR

Hi ...

I am getting the occasional error NRFX_TWI_EVT_BUS_ERROR being reported from the       twi_irq_handler() 

You can see in the following code snippet from this function that NRFX_TWI_EVT_BUS_ERROR will be returned if the error is not one of these

NRF_TWI_ERROR_ADDRESS_NACK

NRF_TWI_ERROR_DATA_NACK

NRF_TWI_ERROR_OVERRUN

 

if (p_cb->error)
{
	uint32_t errorsrc = nrf_twi_errorsrc_get_and_clear(p_twi);
	if (errorsrc & NRF_TWI_ERROR_ADDRESS_NACK)
	{
		event.type = NRFX_TWI_EVT_ADDRESS_NACK;
		NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_ADDRESS_NACK));
		SEGGER_SYSVIEW_RecordString(SYSVIEW_ICT_DEBUG_LOG_STRING, "IIC-NACK-A");
	}
	else if (errorsrc & NRF_TWI_ERROR_DATA_NACK)
	{
		event.type = NRFX_TWI_EVT_DATA_NACK;
		NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_DATA_NACK));
		SEGGER_SYSVIEW_RecordString(SYSVIEW_ICT_DEBUG_LOG_STRING, "IIC-NACK-D");
	}
	else if (errorsrc & NRF_TWI_ERROR_OVERRUN)
	{
		event.type = NRFX_TWI_EVT_OVERRUN;
		NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_OVERRUN));
		SEGGER_SYSVIEW_RecordString(SYSVIEW_ICT_DEBUG_LOG_STRING, "IIC-Ovrn");
	}
	else
	{
		event.type = NRFX_TWI_EVT_BUS_ERROR;
		NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRFX_TWI_EVT_BUS_ERROR));
		SEGGER_SYSVIEW_RecordString(SYSVIEW_ICT_DEBUG_LOG_STRING, "IIC-BErr");
	}
}

The datasheet for the nRF52820 only has 3 errors   A,B,C

Does anyone know what error causes this ?

Do I need to do anything special to recover from it ?

NOTE: I have added the Segger SystemView API calls to the above code to help track the problem. They were not present in the SDK.

Parents
  • Hi,

    What is the state of the bus when this happens? Meaning, is there any specific pattern that you can see that would reproduce this error, such as point in the application where it always assert or some data that is sent on the bus that might be causing the assert? 

    As you write, NRFX_TWI_EVT_BUS_ERROR is a catch-all error if none of the typical errors occurs and can be due to a HW issue. It could also occur when a START or STOP condition occurs when it's not expected. 

    • Could you double check that everything regarding the HW is OK, voltages levels, pullups, cables connected properly etc. 
    • Could you provide a trace from a logic analyzer of SCL and SDA which shows the data and voltage level when it asserts and the call stack when it asserts from debug view.
    • Are you able to reproduce this on a development kit?

    regards

    Jared 

Reply
  • Hi,

    What is the state of the bus when this happens? Meaning, is there any specific pattern that you can see that would reproduce this error, such as point in the application where it always assert or some data that is sent on the bus that might be causing the assert? 

    As you write, NRFX_TWI_EVT_BUS_ERROR is a catch-all error if none of the typical errors occurs and can be due to a HW issue. It could also occur when a START or STOP condition occurs when it's not expected. 

    • Could you double check that everything regarding the HW is OK, voltages levels, pullups, cables connected properly etc. 
    • Could you provide a trace from a logic analyzer of SCL and SDA which shows the data and voltage level when it asserts and the call stack when it asserts from debug view.
    • Are you able to reproduce this on a development kit?

    regards

    Jared 

Children
Related