SEGGER emWin Audio Player Tutorial: Step 13

Step 13: Debug Your Application

Congratulations! You’re done: you are ready to debug Main_Debug_Project.png your application!

1

Insert the micro SD card into the micro SD card slot (J8) on the MEB II board.
Make sure you have loaded the SD card with sample WAV files available under
apps/training/middleware/emwin_media_player/emwin_media_player_lab/dev_files/sample_audio

2

Insert a Flash Drive into the USB Type A receptacle (J5) on the PIC32MZ EF Starter Kit.
Make sure you have loaded the Flash Drive with sample WAV files available under
apps/training/middleware/emwin_media_player/emwin_media_player_lab/dev_files/sample_audio

3

Before you start the debugger, you may want to set a breakpoint in the application file(s) to verify that important stages of the application (such as opening the CODEC driver, mounting the file system on SD card or Flash Drive, initialization of screen, etc) were executed successfully.

Player in SD Card Mode

4

Put a breakpoint in the APP_SDCARD_AUDIO_CARD_MOUNT state in the APP_SDCARD_AUDIO_Tasks() to verify that the file system is mounted on the SD Card. Note: After power up, the SD Card is selected as the default media type.

step13_1_1.png

5

Put a breakpoint in the APP_SDCARD_AUDIO_STATE_CODEC_OPEN state in the APP_SDCARD_AUDIO_Tasks() to verify that the CODEC driver is opened successfully.

step13_1_2.png

6

Put a breakpoint in the APP_DISPLAY_Tasks() to verify that the GUI screen initialization is completed successfully.

step13_1_3.png

7

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

8

The breakpoint in the APP_DISPLAY_Tasks() will be hit first indicating that the GUI screen initialization is complete.
Remove this breakpoint and click F5 to allow the application to run.

9

The breakpoint in the APP_SDCARD_AUDIO_CARD_MOUNT state will be hit next indicating that the file system is mounted on the SD Card. Click F5 to allow the application to run. (You may retain this breakpoint)

10

Next the breakpoint in the APP_SDCARD_AUDIO_STATE_CODEC_OPEN state will be hit which means the CODEC driver is opened successfully.
Remove this breakpoint and click F5 to allow the application to run.
The GUI on the MEB II board should appear as shown below:

step13_1_4.png

The below image identifies various GUI elements of the player.

step13_1_5.png

11

On the GUI screen, click on the Settings Button (8) to open the Settings Window (9). Click on the Play List Switch button to view (show) the Play List (10). The play list should appear on the left side of the GUI and should display all the WAV files present in the SD Card.
(Note: Clicking the Settings Button again will hide the settings window)

12

Connect a headphone to the "HP Out" connector on the Multimedia Expansion Board II.

  • Click on the Play/Pause Button (1) on the GUI to play the first track in the play list.
  • You may increase/decrease the volume by changing the Volume Slider (5).
  • Pressing the Vol Mute Button (4) will mute/un-mute the volume.
  • Random tracks in the play list can be selected either by pressing the Previous Track Button or the Next Track Button or by pressing on the play list item itself.
  • Pressing the Repeat Button (7) will allow you to either:
    • Un-loop the track list (default). Track list will end when the last song in the list is played out.
    • Loop the track list. Track list will loop continuously.
    • Repeat single track. The selected track will loop continuously.
  • Pressing the Shuffle Button (6) will select a random track for playing (after the current track is completed).
  • The Progress Bar/ Seek Bar (12) should increment as the track is being played.
  • You may seek the current track in forward or reverse direction by touching on the Progress Bar/ Seek Bar (12).
  • The current track's elapsed time should increment in intervals of 1 second as the track is being played.
  • Once the current track is complete, the player should select the next track in the play list for playing (Or if the Shuffle Button is pressed a random track will be selected for playing based on the random number generator output).
  • Press the Background Switch (15) button to select between the two background images.

Player in Flash Drive Mode

13

Make sure that the Flash Drive is inserted into the USB Type A receptacle (J5) on the PIC32MZ EF Starter Kit.
Make sure that the breakpoint in the APP_SDCARD_AUDIO_CARD_MOUNT state in the APP_SDCARD_AUDIO_Tasks() is still set.

14

Click on the Settings Button (8) to open the Settings Window (9). Click on the Mode Switch (13) and change the Mode to Flash.

15

The breakpoint in the APP_SDCARD_AUDIO_CARD_MOUNT state will be hit, indicating that the file system is mounted on the currently selected media - Flash Drive. Click on F5 to allow the application to run.

16

The Play List will now be populated with the WAV files available in the connected Flash Drive. Click on the Play Button (1) to listen to the first track in the Play List. All the player functionalities described in Step 11 will be available in the Flash Drive mode also.

17

Remove all the breakpoints and let the application run freely.

18

You may switch between the SD card/Flash Drive modes and verify all the player functionalities.

19

If the Flash Drive is removed while the player is in Flash Drive mode, the player will automatically fall back to the SD Card mode. If the Flash Drive is removed while the player is in SD Card mode, switching the player to Flash Drive mode will display the message "No Audio Files To Play!" in the Play List. The player will display the same message if the Flash Drive does not contain any WAV files.

The plug and play feature of the SD card is not supported. The player does not respond if you remove the SD card and insert it back while the audio was being played. If you want to remove, connect or replace an SD card, Power down the device, remove, connect or replace the SD card, and power up the device.

20

If you have not connected the SD Card, with the player in SD Card mode, the Play List will display the message "No Audio Files to Play!". The player will display the same message if the SD Card does not contain any WAV files.

 Results

You should see an Audio Player Graphical User Interface on MEB II display. The GUI should allow you to select and play WAV files. Through the GUI you should be able to control volume level, mute and un-mute the volume, select random tracks for playing, shuffle the track list, put the track list in repeat mode or repeat a single track. You should also be able to seek the audio track in forward/reverse direction and see the progress bar and the elapsed track time update as the track is played. You may not get the desired audio output (or may not hear any audio) if any of the drivers - CODEC, I2S, I2C and their associated I/O pins, Master Clock and DMA are not configured correctly. You may not be able to view the tracks in the play list if the SD Card or the SPI driver and it's associated I/O pins and File System are not configured correctly. Here, you may also want to make sure that you have loaded the SD card (or Flash Drive) with the sample WAV files. You may want to check the USB Host mode configuration and the File System related configuration if you do not see the track list in Flash Drive mode. If the GUI does not respond to touch, check the Touch driver and it's associated I2C driver configuration along with the I/O pins and the Interrupt pin configuration. You may also want to make sure that you have configured the SEGGER emWin Touch Wrapper correctly. Finally, if you do not see any display on the MEB II board, check the LCC driver configuration and make sure the DMA priority is set to highest. You may also want to check the SEGGER emWin GUI Wrapper configuration.

 Analysis

The lab developed an audio player application using SEGGER emWin graphics library. MHC was used to select the appropriate Board Support Package (BSP) and to configure the clock system, CODEC, I2S and I2C drivers, Audio Decoder for WAV files, SD Card and SPI driver, USB Mass Storage Host Library, SEGGER emWin graphics library, Graphics display, display driver (LCC) and Touch driver, DMA System services, Random Number Generator and File System. The lab also used the SEGGER tools - GUIBuilder to design the GUI. The output of this tool was saved as a C file which was then modified to handle widget events and custom rendering. The BmpCvt (BitMap Converter) utility from SEGGER was used to convert BMP images to C files with reduced bit map size and transparency enabled. The generated C files were integrated and linked with the project. At the application level, two tasks (state machine) were developed. One task for handling the media (SD Card/Flash Drive), audio CODEC and other audio player related activities/events. The second task for handling and forwarding the events generated by the widgets to the appropriate task that can respond to these events and also forwarding the requests generated by the tasks by calling the appropriate widget APIs.

 Conclusions

This lab shows how you can use MHC to create complex and realize real world applications that integrate various peripheral drivers like I2S, I2C, SPI, DMA, Device drivers for CODEC, SD Card, Touch and Display, and libraries for USB Host Mass Storage, File System, Audio Decoder and SEGGER Graphics. It also demonstrated the usage of SEGGER tools to design the GUI. Using the Harmony software framework and MHC frees time for you to spend developing your custom application software. As a next step, you may want to use advance SEGGER graphics library (for example, memory devices) features to create a more powerful and a feature rich GUI.

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