Getting Started with MPLAB® Harmony v3 Peripheral Libraries on PIC32MK GP MCUs: Step 2

Last modified by Microchip on 2023/11/09 09:07

Configure TMR2 Peripheral Library

Click on the Available Components tab in the left pane in the MPLAB® Harmony Configurator (MHC) window.

Expand Peripherals > TMR.
Double click or drag and drop TMR2 to add the Timer2 Peripheral Library (PLIB) to the project graph.

Double click or drag and drop TMR2 to add the Timer2 Peripheral Library (PLIB) to the project graph

Information

In PIC32MK GP devices, by default, TMR2 is configured as a 16-bit timer and is sourced by a 60 MHz Peripheral Bus Clock (PBCLK). Using the default TMR2 configuration, the generation of 500 milliseconds, one second, two seconds, and four seconds period is not possible. To generate 500 milliseconds, one second, two seconds, and four seconds time periods, TMR2 needs to be configured as a 32-bit timer.


In the project graph, configure the TMR2 PLIB as a 32-bit timer and set the timer period as 500 milliseconds.

Configure the TMR2 PLIB as a 32-bit timer and set the timer period as 500 milliseconds


Verify that PBCLK2 is set to 60 MHz.

Verify that PBCLK2 is set to 60 MHz

Configure CORETIMER 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 graph.

Double click on CORE TIMER to add the CORE TIMER PLIB to the project graph

The core timer is configured to use the CORE TIMER PLIB. The CORE TIMER PLIB provides blocking timer delay APIs. The blocking timer delay APIs are needed when initializing the temperature sensor.


In the project graph, use the default CORE TIMER PLIB configuration as shown.

Use the default CORE TIMER PLIB configuration in the project graph

Back to Top