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!

1

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:
apps/training/middleware/thumb_drive_player/thumb_drive_player_lab/dev_files/sample_audio.

2

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

3

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.

image_107.png

4

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.

image_108.png

5

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

image_109.png

6

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

7

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

8

You should see the display now. Notice that the display looks exactly the same as the one simulated using MPLAB® Harmony Graphics Composer (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.

9

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

10

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 tracklist and start playing the audio.

 Results

You should see a GUI on the MEB II display populated with a list of tracks read from the flash drive along with volume and mute control. The UI 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 (I²C, I²S, etc.), CODEC, USB Library or the Graphics Library were not configured correctly.

 Analysis

This lab developed an audio player that reads WAV files from a USB Flash drive. It also added graphics support to display the tracklist and control volume. MPLAB Harmony Configurator (MHC) was used to select the appropriate Board Support Package (BSP) and to configure the clock system, CODEC driver (I²S and I²C), Audio Decoder for WAV files, USB Mass Storage Host Library, Direct Memory Access (DMA) System services, Timers, and File System. The MHGC was used to design and develop the GUI. A display driver and touch driver (I²C 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.

 Conclusions

This lab shows how you can use MHC to create complex applications that integrate various peripheral drivers like I²S, I²C, 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.

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