MPLAB® Harmony v2 Portability

Code Portability From Device to Device

Source code utilizing MPLAB® Harmony libraries for one PIC32 device can be easily reused for another PIC32 device. Harmony is based on Microchip peripherals and designed around those peripherals. These abstracted libraries make the peripherals easier to use. So, regardless of which part you’re using, these libraries use the same (or nearly the same) interface.

This code portability dramatically reduces the time it takes to migrate code from one device to another. This lowers Non-Recurring Engineering (NRE) charges for code development and shortens the time to market.


Consistent API

The way MPLAB Harmony libraries provide portability is by providing a consistent, well-defined, and well-documented set of interface functions that do not change from part to part as long as the same feature is supported by both parts.

The following graphic shows a section of the Harmony help file that describes and defines the Harmony timer Peripheral Library (PLIB). Notice the content tree on the left describes the library’s abstraction model, provides sections on how to use the library, and manage different timer configurations (synchronous, asynchronous, gated, and others). This is vital information that would be missing if MPLAB Harmony only provided a header file to document the library.

The Library Interface topic, shown on the right, provides a nice hyperlinked table that breaks down and lists all of the functions and data types (and other elements) that make up the interface to the timer PLIB. This provides a handy programmer’s reference when you’re using a library and you want a reminder of the supported functions and its parameters.


Code Example

This code is an example of what a simple blinking light demo might look like when using a PLIB. Notice the clear and consistent naming convention. The inversion of verb and object may seem a little odd at first but it groups the functions alphabetically and helps make the library easier to understand. Also, notice that you can easily tell what the program is doing because the function names describe what they do.


This code example is exactly the same as the previous example, but it was written for a different PIC32 device. Note the PLIB function names stay the same.

The function definitions for these PLIBs may change slightly from part to part but you don't have to worry about this. Just include Harmony's device-specific library file in your project. This file frees you from dealing with the peripheral configuration details for a specific device. For example, you will not have to know the name of the Timer0 enable bit and its resident register.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.