USB Flash Drive Audio Player Tutorial: Step 10

Step 10: Debug Your Application

Congratulations! You are ready to DEBUG Main_Debug_Project.png the application!


Before the application is programmed and run, make sure that the flash drive has some WAV audio files saved on it. There are some sample WAV audio files provided in this folder:


Connect the flash drive to USB port J5 on the PIC32MZ EF Starter Kit.


Before you start the debugger, you may want to set a breakpoint in app_thumb_drive_player.c under the APP_THUMB_DRIVE_AUDIO_STATE_WAIT_FOR_DEVICE_ATTACH switch case, to verify that the file system is mounted on the attached flash drive.



You may also want to put a breakpoint in app_thumb_drive_player.c under the APP_THUMB_DRIVE_AUDIO_STATE_CODEC_OPEN switch case, to verify that the CODEC driver is opened successfully.



Finally, you may want to check if the graphics library has completed populating the GUI. Put a breakpoint in app_display_task.c (as shown below) to verify.



Debug your application! Click the Debug Main Project Main_Debug_Project.png icon.


After verifying that all the breakpoints are hit, remove them and press key F5 and allow the application to run.


You should see the display now. Notice that the display looks exactly the same as the one simulated using MHGC. The GUI will be populated with the WAV files available in the flash drive. The first file in the tracks list box is selected and played.


Connect your headphones to the HP Out connector on the Multimedia Expansion Board II to hear the audio tracks. Experience various UI features like volume slider and mute/un-mute.


Remove the flash drive and notice that the GUI displays a message saying "Device is disconnected". Re-insert the flash drive and the GUI will again populate the track list and start playing the audio.


You should see a graphical user interface on the MEB II display populated with a list of tracks read from the flash drive along with volume and mute control. The user interface should respond to touch events and you should be able to select random tracks for playing, increase or decrease volume level and mute the audio output. You might not get the intended results if the drivers (I2C, I2S, etc.), CODEC, USB Library or the Graphics Library were not configured correctly.


This lab developed an audio player that reads WAV files from a USB flash drive. It also added graphics support to display the track list and control volume. MHC was used to select the appropriate Board Support Package (BSP) and to configure the clock system, CODEC driver (I2S and I2C), Audio Decoder for WAV files, USB Mass Storage Host Library, DMA System services, Timers and File System. The MPLAB® Harmony Graphics Composer (MHGC) was used to design and develop the graphical user interface. A display driver and touch driver (I2C based) was added from the list of supported driver implementations. Custom actions were added to handle various UI events like touch, pressed, released etc.

At the application layer, two tasks (state machines) were added. One task to handle the USB flash drive, CODEC and audio player related activities, and the other task to handle graphics related activities like populating the display with the list of tracks read from the flash drive, handling track change event, volume increase/decrease and mute events.


This lab shows how you can use MHC to create complex applications that integrate various peripheral drivers like I2S, I2C, DMA, Timers, Device drivers for CODEC, Touch and Display, and libraries for USB Host Mass Storage, File System, Audio Decoder and Graphics. Using the Harmony software framework and MHC frees time for you to spend developing your custom application software.

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