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 the 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 I2S interface which gets played on the audio CODEC. The lab demonstrates basic system initialization and polled state machine design.
Lab Source Files and Solutions:
If you haven't already downloaded all source files for the SD card Audio Player labs:
Download the lab source files and solutions >
This project has been verified to work with the following versions of software tools:
MPLAB X IDE v3.26, MPLAB XC32 Compiler v1.40, MPLAB Harmony v1.08
Because we regularly update our tools, occasionally you may discover an issue while using newer versions. If you suspect that to be the case, we recommend that you double check using the same versions that the project was tested with.
Archived versions of our tools can be found on the following Microchip websites:
MPLAB Harmony (see "Archived Downloads" tab)
MPLAB X IDE and XC32 Compiler (see "Downloads Archive" tab)
Note that multiple versions of all these tools can co-exist on the same computer.
All steps must be completed before you will be ready to build, download and run the application.
Part 1: Create project and configure the PIC32MZ
- Step 1 – Create an MPLAB® Harmony project in the MPLAB X IDE
- Step 2 – Using MHC, select the Board Support Package
- Step 3 – Using MHC, verify Configuration Bits are correct
- Step 4 – Using MHC, verify Oscillator Settings
- Step 5 – Using MHC, verify I/O pins using the Graphical Pin Manager
- Step 6 – Using MHC, configure the audio CODEC AK4953, I2C driver and I2S driver
- Step 7 – Generate Harmony code and build project
Part 2: Add Application Code
- Step 8 – Include application specific source files and add required code
- Step 9 – Review the application code
- Step 10 – Debug your new application
Step 1: Create an MPLAB Harmony project in the MPLAB X IDE
Step 2: With MHC, Select the Board Support Package (BSP)
Step 3: With MHC, Verify Configuration Bits are correct
Step 4: Verify and Change Oscillator Settings
Step 5: With MHC, Verify I/O pins using the Graphical Pin Manager
Step 6: With MHC, Configure Audio CODEC AK4953, I2C driver and I2S driver
Step 7: Generate Harmony code and build project
Step 8: Include application specific source files and add required code
Step 9: Review the application code
Step 10: Debug your new application
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, I2S 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.
In this lab you have successfully played a sine tone on the PIC32 microcontroller and heard the audio through the headphone on the development board. The sine tone produced is 16-bit, 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 (MPLAB Harmony Composer) 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.
In this lab you have successfully developed a full fledged MPLAB Harmony Application. This gives you a fair idea of how MPLAB harmony eases 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.
Table of Contents