MPLAB® Harmony 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 very nearly the same) interface.

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

devices.jpg

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 contents tree on the left describes the library’s abstraction model and 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 peripheral library. This provides a handy programmer’s reference when you’re using a library and you just want a reminder of what functions it supports and what their parameters are.

api.jpg

Code Example

This code is an example of what a simple “blinky light” demo might look like when using a peripheral library. 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.

mx1_code.jpg
arrow.jpg
mx7_code.jpg

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

The function definitions for these peripheral libraries 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 which register it lives in.

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
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.