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.

  • 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 

  • Hi,

    Attached is a logic analyzer capture showing then then problem occurs

    You can see that the stop bit is never generated by the IIC nRF52820, then the error NRFX_TWI_EVT_BUS_ERROR is raised

    I am using 2k2 pullups in the IIC bus to 3V3 and voltages look ok.

    The IIC chip is on the same PCB as the CPU, so there are no cables

  • Hi,

    Are you able to reproduce this on a development kit?

    regards

    Jared 

  • Hi...

    I don't have a dev kit to test this on..  

    The IIC Bus on our product has 2K2 pull ups and has these devices connected to it

    24LC64   (EEPROM)

    CLRC66303    (RFID Reader)

    SAMV3           (Secure Access module)

    CPT212B       (Cap Touch)

    Thanks

    Ray

  • Hi,

    It would be great if you could acquire one because I suspect that the root cause is due HW. But before you do that I could review your design if you share your schematics, and relevant code which is used to reproduce the issue.

    Thank you

    regards

    Jared 

Related