3.5.1 Application Example Using MPLAB Harmony v3 PLIB in Blocking Mode
In blocking mode, the interrupt for the PLIB is disabled. The APIs for the transfer request operate in blocking mode. Because the APIs block until completion, there is no need of any mechanism to check the transfer status.
In this mode, the application can be created using the following steps:
- Create the MPLAB Harmony v3 project.
- Follow these steps to 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.
- Follow these steps to
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, the configuration options will appear on the right.
- Clear Interrupt mode
and change the baud rate to 115,200 as shown in the following
figure.
Figure 3-3. Configuring UART PLIB 1
- 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 written to initialize the UART peripheral.
- The following code shows the
two lines of code (shown in bold) used to implement an application to
display a message on the
console.
uint8_t consoleMsg[] = "Hello World\n\r"; int main ( void ) { /* Initialize all modules */ SYS_Initialize ( NULL ); UART6_Write(&consoleMsg[0], sizeof(consoleMsg)); while ( true ) { /* Maintain state machines of all polled MPLAB Harmony modules. */ SYS_Tasks ( ); } /* Execution should not come here during normal operation */ return ( EXIT_FAILURE ); }