Lab 1: Audio-Tone Generation Using a Lookup Table With MPLAB® Harmony v3

Last modified by Microchip on 2024/01/29 18:22

Warning: This tutorial uses the old Harmony configuration tool (MPLAB® Harmony Configurator (MHC)). New Harmony projects should use the MPLAB Code Configurator (MCC) instead.



After completing this lab, you will have an understanding of the fundamental elements, layout, and execution model of an MPLAB® Harmony project. You will also learn how to add features and functionality to your MPLAB Harmony project by using MPLAB Harmony Configurator (MHC).


In this lab, you will create a simple MPLAB Harmony project from scratch. You will use MHC to configure the codec on the PIC32 Multimedia Expansion Board II. The application streams an audio tone (stored in the form of a lookup table in memory) over the I²S interface which gets played on the audio codec. The lab demonstrates basic system initialization and polled state machine design.


App_Tasks() state diagram


APP_TONE_LOOKUP_TABLE_Tasks() state diagram

Back to top

Reference Materials

Download the lab source files and solutions for the SD card audio player labs.

This project has been verified to work with the following versions of software tools:

  • MPLAB X IDE v5.25
  • MPLAB XC32 Compiler v2.30
  • MPLAB Harmony MHC v3.3.2, DEV_PACKS v3.5.0
  • CORE v3.5.0, CSP v3.5.0, BSP v3.5.0
  • AUDIO v3.4.0

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 on the following pages:

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

Back to top


All steps must be completed before you will be ready to build, download, and run the application.

Part 1: Create a Project and Configure the PIC32MZ

Part 2: Add Application Code

Back to top


You should be able to hear a sine tone output through the headphone jack on the Multimedia Expansion Board II. If you did not configure the codec driver, I²S driver or REFCLOCK properly, you may not hear the audio at all or may hear distorted audio coming out with clicks and pops in the stream.

Back to top


In this lab, you have successfully played a sine tone on the PIC32 microcontroller and heard the audio through the headphone jack on the development board. The sine tone produced is 16-bits, at a 48000 sampling rate. The tone as such was produced statically and stored in the form of a lookup table in an array. MHC was used to configure the hardware modules. The application was developed in a state-based implementation. In the application, audio buffer management was done by using the buffer queuing support provided by the codec driver.

Back to top


In this lab, you have successfully developed a full-fledged MPLAB Harmony Application. This gives you a fair idea of how MPLAB Harmony helps application development. If you need to add audio support to any of your existing applications, this lab can be used as a reference. This can also be a starting point for your applications which are audio intensive.

Back to top