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:
- Create the MPLAB Harmony v3 project.
- Configure using the MCC:
- Configure the UART Pin: Launch the pin manager, go to the Pin Setting window of the MCC and configure the UART Transmit pin.
- Configure the UART PLIB:
- Add the UART6 Peripheral Library from the Device Resources list.
- Click on the added UART6 PLIB box on the project graph to see its configuration options in the window to the right.
- 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
- Generate the code using the MCC.
- Update the
main.c
file.- 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.
- 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.