3.5.2 Application Example Using MPLAB Harmony v3 PLIB in Non-Blocking (interrupt) Mode

In Non-Blocking mode, the interrupt for the PLIB is enabled and the API that submits the transfer request does not block until the transfer completes. Instead, the transfer request API is called, the API triggers the transfer process, and it immediately returns. The CPU continues to run the following instructions while the transfer happens in the background. However, because the interrupts are enabled in this mode, CPU execution is interrupted (to execute Interrupt service routines) after every transfer completion until the whole transfer request is completed. In the Interrupt mode of implementation, the transfer status can be checked in the following two ways. The user can choose one of the methods to check the transfer status as required.

  • Status Polling: The MPLAB Harmony v3 PLIBs provide an IsBusy API to poll the status of the transfer.
  • Callback: The MPLAB Harmony v3 PLIBs provide a callback register API to register the callback. If the callback is registered, the registered callback function is called by the PLIB upon the transfer completion.