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

Use TWI in blocking mode

1.How do I use TWI \ TWIM Read\Write in blocking mode ? 

I am facing an issues with my nrf52840 based design, where I issue consecutive TWI write\read . 

I am monitoring the I2C bus transaction with Logic Analyzer. When executed step-by-step ( debug ) , all transactions goes well on the bug. 

( or when using 200 ms delay between transactions for ex.  ) 

When "running" ( no bkp ) - the transactions are not complete , so it seems that I am writing\reading a new transaction while the previous is on-going. 

I'd like to use the TWI in a complete blocking mode ( i.e not returning before transaction is completed , using xfer-done and events is complicated in my case ) 

Thanks, 

Ran

Parents
  • If the event_handler parameter is passed as NULL in nrf_drv_twi_init(). TWI will be put in blocking mode.
    From the SDK

     * @param[in] event_handler   Event handler provided by the user. If NULL, blocking mode is enabled.
    
    ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const *        p_instance,
                                nrf_drv_twi_config_t const * p_config,
                                nrf_drv_twi_evt_handler_t    event_handler,
                                void *                       p_context);


Reply
  • If the event_handler parameter is passed as NULL in nrf_drv_twi_init(). TWI will be put in blocking mode.
    From the SDK

     * @param[in] event_handler   Event handler provided by the user. If NULL, blocking mode is enabled.
    
    ret_code_t nrf_drv_twi_init(nrf_drv_twi_t const *        p_instance,
                                nrf_drv_twi_config_t const * p_config,
                                nrf_drv_twi_evt_handler_t    event_handler,
                                void *                       p_context);


Children
Related