Objective

MPLAB® Harmony provides the capability to quickly develop complex embedded systems that utilize multiple middleware stacks running at the same time in a Real-Time Operating System (RTOS) or non-RTOS system.

The following exercises demonstrate the quick prototyping capability of MPLAB Harmony. These exercises should be completed in a sequential manner in order to understand how the following exercise enhances and adds new functionality to the earlier exercise.

Two ways to use this tutorial:

Create the projects from scratch

Use the provided source files and step-by-step instructions for each lab.

Use the solution project as an example

Just build the solution project (found in the lab's firmware folder) and download it to the MEB II board to observe the expected behavior.

Objectives

Create an MPLAB® X IDE Harmony project for a PIC32 microcontroller from scratch.

Materials

Hardware Tools

It is not necessary to have an MPLAB Real ICE™ to program/debug the code. The PIC32MZ EF Starter Kit includes a PICkit™ on-board (PKOB) debugger. The PKOB debugger can be connected to a host PC through the USB Mini-B connector on the PIC32MZ EF Starter Kit for programming/debugging (see the red cable in the hardware setup)

Apart from the hardware tools listed above, the following items are required to play audio from an SD card and to load audio files into the SD card over a USB interface from the PC:

Software Tools

​

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.

Harmony SD card Audio Player/Reader Labs

The associated ZIP file contains the completed solution of these five labs. The completed solution is not needed to develop the labs from scratch; it can be used as an example and requires no modifications. To gain a deeper understanding of how to use the MPLAB Harmony framework for Quick Audio Prototyping, and creating an SD card Audio Player/Reader, we recommend you follow the step-by-step procedures detailed in the "Procedure" section below.

Lab1: Audio tone generation using the lookup table

Lab2: Audio tone generation using text file stored in SD card

Lab3: SD card reader support to load audio files

Lab4: Play WAV audio file from SD card

Lab5: Display graphics support to select and play an audio file

Lab Source Files and Solutions

This ZIP file contains the completed solution projects for all labs associated with this SD card audio player tutorial. It also contains the source files needed to perform the labs per the following step-by-step instructions (see the "Procedure" section on this page).

Results

Lab1: You should be able to hear a sine tone output through the headphone jack on the Multimedia Expansion Board II (MEB II).

Lab2: As in Lab1, you should be able to hear a sine tone output through the headphone jack on the MEB II.

Lab3: You should be able to load audio files to the SD card by connecting the MEB II to a PC over the USB interface. The MEB II will act as a USB Mass Storage Device.

​

For Lab3, you will be able to play audio data saved in a tone.txt file by loading it through the USB interface. For subsequent labs, you will be able to play WAV files by loading them to the SD card using the USB interface.

Lab4: You should be able to play, and hear audio tracks (WAV files) played on your headphones connected to the MEB II.

Lab5: You should see a graphical user interface on the MEB II display, populated with a list of audio tracks (WAV files) read from the SD card, along with volume and mute control. The user interface should respond to touch events and you should be able to select random tracks for playback, adjust the volume level and mute/unmute the audio output.

Problems with the results of each lab could occur if you don't carefully follow the detailed steps provided. Also, note that each lab is an extension of the previous lab; successful completion of earlier labs is essential for following labs to work.

Analysis

In this exercise series, we have successfully developed an audio solution right from the basic tone playback to an SD card audio player. We added graphics display support and also added support for an SD card reader. Using the MHC we configured the hardware modules including Clock, CODEC driver, Reference clock for the CODEC, I2S driver, SPI driver, SD card driver, GFX library and USB Library. Each of the lab applications was developed in a state-based, loosely coupled implementation. The state-based implementation and loose coupling enabled easily enhancing subsequent labs.

Conclusions

By the end of this lab series, you will have successfully developed a fairly complex audio solution in a fairly short time. By now you should appreciate the real power of MPLAB Harmony, particularly the power of MHC and the ease with which it allows you to add/remove software modules to an existing developed application. With this lab series completed, you are now in the position of creating complex applications using PIC32 microcontrollers. MPLAB harmony provides all the necessary software tools which will enable you to quickly develop your application. If you want to expand on this exercise series try adding more software components such as the TCP/IP stack, or add application support for audio recording.

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.

Click here to edit contents of this page.

Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.

Append content without editing the whole page source.

Check out how this page has evolved in the past.

If you want to discuss contents of this page - this is the easiest way to do it.

View and manage file attachments for this page.

A few useful tools to manage this Site.

See pages that link to and include this page.

Change the name (also URL address, possibly the category) of the page.