3.5.2.1 Application Example Using Status Polling

Follow these steps to create the example application to display a message on the console using the MPLAB Harmony v3 PLIBs in Non-Blocking (interrupt) mode using status polling:

  1. Create the MPLAB Harmony v3 project.
  2. Configure using the MCC:
    1. Configure the UART Pin: Launch the pin manager, go to the Pin Setting window of the MCC and configure the UART Transmit pin.
    2. Configure the UART PLIB:
      1. Add the UART6 Peripheral Library from the Device Resources list.
      2. Click on the added UART6 PLIB box on the project graph to see its configuration options in the window to the right.
      3. Keep the interrupt mode enabled and change the baud rate to 115,200 as shown in the following figure:
        Figure 3-4. Configuring UART PLIB 2
  3. Generate the code using the MCC.
  4. Update the main.c file.
    1. The UART initialization code is already generated by the MCC based on the configuration done in step 2.2 above, hence code is not required to initialize the UART peripheral.
    2. Update the main.c file with the following code to complete the application implementation:
      uint8_t consoleMsg[] = "Hello World\n\r";
      
      int main ( void )
      {
          /* Initialize all modules */
          SYS_Initialize ( NULL );
          
          UART6_Write(&consoleMsg[0], sizeof(consoleMsg));
          while (UART6_WriteIsBusy());
          
          while ( true )
          {
              /* Maintain state machines of all polled MPLAB Harmony modules. */
              SYS_Tasks ( );
          }
      
          /* Execution should not come here during normal operation */
      
          return ( EXIT_FAILURE );
      }
      
Note: The application code in non-blocking (interrupt) mode is similar to that of blocking mode. non-blocking mode has one extra instruction (as shown in bold above) to poll the status of the transfer.