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

TWI Stuck Bus Recovery

What is the best method for attempting to recover from a stuck TWI bus after init?

I am currently initializing the TWI instance with .clear_bus_init=true but this only happens once during the init.

For example in the past we have had some issues with EMI inducing signals on the TWI bus which caused some devices to hold the bus in a read operation. In the past we used a 'General Call Reset' after a specific number of read failures.

So again I ask my question What is the best method for attempting to recover from a stuck TWI bus after init? using the SDK.

Thanks, Darren

  • Hi Darren,

    I discussed this with the developers and their recommendation was to reinitialize the TWI driver.

    However, there is an internal twi_clear_busfunction in nrf_drv_twi.c that you could expose and use, but I would recommend the first solution, i.e. reinitialization of the driver.

    Best regards

    Bjørn

  • Bjorn,

    Thanks for talking with the developers on this. I had come to the same conclusion but I wanted to make sure that I wasn't missing something.

    As always the support at Nordic is awesome!

    Thanks, Darren

  • No problem and thanks :)

  • Hey,

    I also have a similar problem for which I need to clear the bus. I'm using nRF52840. My question is do we need to uninitialize and reinitialize or just only reinitialize without uninitialize is sufficient? Also, is it fine to do this re-initialization before every TWI transaction?

  • Yes, you have to uninitialized reinitialize the TWI driver you else you will get an NRF_ERROR_INVALID_STATE when you init the driver.

1 2