ADC Project Using chipKIT® Wi-FIRE for Harmony v2


This example project uses the ADC in the PIC32 to convert a voltage from analog to digital and display the magnitude of the result on the four LEDs found on the Digilent® chipKIT® Wi-FIRE development board.

The MPLAB® Harmony ADC Driver and Peripheral Libraries are used to achieve this. The MPLAB Harmony Configurator (MHC) is used to configure the ADC Driver to generate an interrupt after acquiring and converting sixteen samples. The Interrupt Service Routine (ISR) calls a function to read and average the results from the ADC results buffer. It also sets the dataReady flag, indicating it's time to update the LEDs with the new ADC result.

The code you will add to this example project (as described in the following steps) implements the state machine shown in the diagram below:


The "Project and Source Files" download (see below) contains a fully functional project. It can be used as an example and requires no modifications. To gain a deeper understanding of how to use the MPLAB® Harmony framework, we recommend you generate the project and source files yourself by following the step-by-step procedure below.


Hardware Tools

Tool About Purchase
chipKIT™ WF32
Development Board

Software Tools

This project has been verified to work with the following versions of software tools: MPLAB® X IDE v3.30, MPLAB® XC32 Compiler v1.40, MPLAB® Harmony v1.08

As the tools are regularly updated, there may be occasional issues while using newer versions. If that is the case, we recommend using the same version as specified in the project.

The archived versions of our tools can be found below:
MPLAB Harmony
MPLAB X IDE and XC32 Compiler

Note that multiple versions of all these tools can co-exist on the same computer.

Tool About Installers
Windows Linux Mac OSX
Integrated Development Environment
C/C++ Compiler
MPLAB® Harmony 1.xx
Integrated Software Framework

Exercise Files

The contents of the following ZIP file need to be placed in this directory. If this is not done, the MPLAB X IDE will not be able to find all source files, and the project will not build successfully.

<Harmony install path>/apps/training
(example Harmony install path = c:/microchip/harmony/v1_08)

File Download
Windows Linux Mac OSX
Project and Source Files


The Project and Source Files download provides a fully functional project. It can be used as an example and requires no modifications. Below are the step-by-step instructions on how the project was created:


Create a new MPLAB® Harmony project

The Target Device used on the chipKIT Wi-FIRE is the PIC32MZ2048EFG100.


Use the BSP to load appropriate default values for the PIC32 core, clocks, and I/O port pins.


Use MHC to enable and configure the ADC Driver


Use MHC to enable and configure the Timer Driver


Use MHC to generate the code


Add application states and variables to your project in the header file APP


Add code to the ADC Interrupt Service Routine.


Create the function to display the newest ADC result on the LEDs.


Initialize the dataReady flag to false in the application initialization function.


Create the APP_Tasks() function to implement the application's state machine.


Connect the development board and programmer/debugger to your computer, then select the XC32 compiler version and programmer/debugger for the project


Build, program and run your project

Click the Run icon Main_Run_Project.png to build, program and run your project.


After successfully programming the device, at least one LED will turn on. Turning the POT all the way to the left will light a single LED. As you turn the POT to the right, more LEDs will turn on (similar to a volume indicator).


This example project demonstrates much more than configuring, monitoring, and controlling the PIC32 ADC. You've also learned the basic program architecture common to all MPLAB Harmony projects.

© 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.