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

Are TWI transfers of twi_master.h blocking?

I want to know if they are safe to call from within an IRQ (e.g. app_timer).

Parents
  • Hi

    The TWI drivers provided in the SDK are blocking. However, there is a library available here where you can choose blocking or non-blocking TWI operations.

    The TWI should behave like any other on-chip peripheral, see this thread. The application timer callback has the same priority as other peripheral and softdevice callbacks, so if you call blocking function from a IRQ handler like the application timer handler, then you will be blocking all other callbacks until the operation finishes. All BLE operations have higher priority so they will not be blocked.

    It is however good practice to call the scheduler from interrupt handler if the task to perform is time consuming, thereby executing the task in the main context instead. That way, potential callbacks will only be blocked for a short time.

Reply
  • Hi

    The TWI drivers provided in the SDK are blocking. However, there is a library available here where you can choose blocking or non-blocking TWI operations.

    The TWI should behave like any other on-chip peripheral, see this thread. The application timer callback has the same priority as other peripheral and softdevice callbacks, so if you call blocking function from a IRQ handler like the application timer handler, then you will be blocking all other callbacks until the operation finishes. All BLE operations have higher priority so they will not be blocked.

    It is however good practice to call the scheduler from interrupt handler if the task to perform is time consuming, thereby executing the task in the main context instead. That way, potential callbacks will only be blocked for a short time.

Children
Related