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

TWI Clearing Bus with NRFX_TWI driver

Hello,

We are using the NRFX_TWI driver which we understand is a new and improved version of the legacy NRF_DRV_TWI driver.  However we are getting a number of apparent stuck-bus errors if our app breaks in the wrong place, and have to completely remove power from the system to get everything un-stuck (simply restarting the code does not help).

It appears this is a common problem and the solution given in https://devzone.nordicsemi.com/f/nordic-q-a/21508/twi-stuck-bus-recovery seems to be simple enough.  However I cannot find an analog for the NRFX_TWI driver, as this is not a valid parameter in the config_t struct:

static const nrfx_twi_config_t twi_config = {
.scl = TWI_SCL,
.sda = TWI_SDA,
.frequency = NRF_TWI_FREQ_400K,
//.clear_bus_init=true, //does not work
.interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY};

Could you advise as to how to clear the bus?

Thanks!

--Allen

Parents
  • Hi Allen,

    As I understand it, NRFX drivers are not the replacement for nrf_drv.

    We want to use the same hal layer over different solutions we have so that the underlying hal layer is not implemented in different ways in different solutions.

    So the nrf_drv_twi API is still the same, the change is that now it uses nrfx_twi below it.

    And in SDK15 you still have the same API for nrf_twi and you still have the clear_bus_init option.

    Now assuming that you know all the above, if you say that the clear_bus_init option is not working. then I am little confused as this option just uses the gpio set clear option and it has not changed at all.

        if(p_config->clear_bus_init)
        {
            /* Send clocks (max 9) until slave device back from stuck mode */
            twi_clear_bus(p_config);
        }

  • Hi Aryan,

    I'm currently in the same position, porting to SDK15 and ran into that issue. As I understood, the nrfx drivers are the replacement for nrf_drv ones. In fact, as I understand it, the nrf_drv drivers don't exist anymore, and in the new SDK there's only a translation layer, that translates calls to the old API into calls to the new nrfx API.

    Can you explain what is that piece of code that you posted? Where did you get it from? Thanks for your help!

Reply
  • Hi Aryan,

    I'm currently in the same position, porting to SDK15 and ran into that issue. As I understood, the nrfx drivers are the replacement for nrf_drv ones. In fact, as I understand it, the nrf_drv drivers don't exist anymore, and in the new SDK there's only a translation layer, that translates calls to the old API into calls to the new nrfx API.

    Can you explain what is that piece of code that you posted? Where did you get it from? Thanks for your help!

Children
No Data
Related