MPLAB® Harmony v3 Peripheral Libraries on PIC32MX 470: Step 2
Configure TMR2 Peripheral Library
Click on the Available Components tab in the left pane of the MPLAB® Harmony Configurator (MHC) window. Expand Peripherals > TMR.
Double-click or drag and drop TMR2 and TMR3 to add the Timer2 and Timer3 Peripheral Libraries (PLIBs) to the project.
In the Project Graph window, configure the TMR2 PLIB as a 32-bit timer and set timer period as 500 milliseconds. Once TMR2 PLIB is configured as 32-bit timer, TMR2 and TMR3 work together as a single 32-bit timer.
In the Project Graph window, verify the TMR3 PLIB is set to generate a compare interrupt on every 500 milliseconds.
Verify that the PBCLK is set to 48 MHz.
Configure CORE TIMER Peripheral Library
Under the Available Components tab, expand Peripherals > CORE TIMER.
Double-click on CORE TIMER to add the CORE TIMER PLIB to the project.
In the Project Graph window, use the default CORE TIMER PLIB configuration as shown.
Configure I²C PLIB and I²C Pins
Under the Available Components tab, expand Peripherals > I²C.
Double-click on I²C1 to add the I²C instance 1 to the project.
Select the I²C1 Peripheral Library and use the default configuration as shown.
Open the Pin Configuration tabs by clicking Tools > Pin Configuration.
Now, select the MHC Pin Table tab and then scroll down to the I²C1 module as shown.
- Enable I²C Clock (SDA1) on RD9 (Pin #43)
- Enable I²C Data (SCL1) on RD10 (Pin #44)
Configure Universal Asynchronous Receiver Transmitter (UART) PLIB and UART Pins
Under the tab Available Components tab, expand Peripherals > UART.
Double-click on UART2 to add UART instance 2 to the project.
Select the UART2 Peripheral Library and configure it as shown in the accompanying image.
Verify the default baud rate is set to 115200 Hz.
Select the Pin Table tab and then scroll down to the UART2 module as shown below.
Enable UART_TX (U2TX) on RE5 (Pin #1).
Configure DMA PLIB
Open the DMA Configurator tab by clicking Tools > DMA Configuration.
In the DMA Settings window, enable and configure Direct Memory Access (DMA) Channel 0 to transfer application buffer to the UART TX register as shown. The DMA transfers one byte from the user buffer to UART transmit buffer on each trigger.
- The Priority drop-down option for a channel helps give priority to a DMA channel over the other when more than one DMA channel is configured by the application. Since in this application, only one DMA channel is configured, the default priority (zero or CHPRI0) is not changed.