Voice Recorder Tutorial: Step 7

Step 7: Include Application Specific Source Code and Files

1

Copy the following application source files into the folder containing the project's source files:
app_voice_record_loop.c,
app_voice_record_loop.h,
app_voice_record_store.c,
app_voice_record_store.h,
app_sdcard_audio_task.c,
app_sdcard_audio_task.h,
decoder.c,
decoder.h,
app_display_task.c, and
app_display_task.h
from this folder:
apps/training/middleware/voice_recorder/voice_recorder_lab/dev_files
to this one:
apps/training/middleware/dev/voice_recorder/voice_recorder_lab/firmware/src.

Step12_1.PNG

2

Add
app_voice_record_loop.c,
app_voice_record_store.c,
app_sdcard_audio_task.c,
decoder.c, and
app_display_task.c
to the Source Files/app folder (in the MPLAB® X IDE Projects pane) by right clicking and selecting Add Existing Items…

Step12_2.PNG
Step12_3.PNG

3

Add
app_voice_record_loop.h,
app_voice_record_store.h,
app_sdcard_audio_task.h,
decoder.h, and
app_display_task.h
to the Header Files/app folder by right clicking and selecting Add Existing Item…

Step12_4.PNG
Step12_5.PNG

The files under the project should look like this:

Step12_6.PNG

4

This step is needed to work around an issue related to Harmony version 1.08. The I²S driver file drv_i2s_dma.c needs to be replaced. If you are using a newer version, you may skip this step.

Replace the existing Harmony I²S driver file drv_i2s_dma.c.

Copy the drv_i2s_dma.c file from this folder:
apps/training/middleware/voice_recorder/voice_recorder_lab/dev_files/i2s
to this one:
framework/driver/i2s/src/dynamic
Make sure to create a backup of the existing drv_i2s_dma.c.

Step12_7.PNG

5

This step is needed to work around an issue related to Harmony version 1.08. This version locates the audio decoder libraries in a demo application under the …/v1.08/apps folder. These libraries should instead be located under the …/v1.08/framework folder. It is anticipated that Harmony version 1.09 will address this issue.

Harmony version 1.08 provides audio decoder libraries in one of the many demo applications that are included in the Harmony download. They can be found here:
<Harmony install path>/apps/audio/universal_audio_decoders/firmware/src/audio_decoder
Note: Harmony version 1.09 will move these libraries under the …/framework/decoder folder. If you are using v1.09, you can skip this step.

Your project needs to use the WAV decoder found in the universal_audio_decoders demo application. Let the compiler know where it can find these source files.

To include this path, right click on thumb_drive_player_lab in the Projects pane and select Properties. In the Categories pane, select:
Conf: [pic32mz_ef_sk_meb2] > XC32 (Global Options) > xc32-gcc.

In the Option categories dropdown menu, select Preprocessing and messages.

Step12_8.PNG

Click on Include directories.

Step12_9.PNG

Browse (click on the button) to this path:
<Harmony install path>/apps/audio/universal_audio_decoders/firmware/src/audio_decoder and
Click OK.

Step12_10.PNG
Step12_11.PNG

6

Open the file app.c (in the MPLAB X IDE Projects pane under the Source Files/app folder) and add the following code to the APP_Initialize function:

Step12_12.PNG

7

Also in app.c, add the following tasks to the APP_STATE_SERVICE_TASKS state in the APP_Tasks function.

Step12_13.PNG

8

Add the following simple utility functions to app.c. You can locate these functions at the end of the file.

Step12_14.PNG

9

Declare the functions you added in the previous step to app.h.

Step12_15.PNG

10

Add the following enumerations to app.h. This typedef section can be found about a third of the way down from the top of the file.

Step12_15_1.PNG

11

Also, add the following members to the APP_DATA structure in app.h.

Step12_15_2.PNG

12

Open the app.h file and include this file:
app_sdcard_audio_task.h.
The decoder file wav.c depends on definitions present in other files and expects app.h to include those files.

Step12_16.PNG

13

Finally, open system_config.h and include the following application-specific definitions. You will find this section near the bottom of the file.

Step12_17.PNG

14

You are now ready to build the code! Click the Clean and Build Main_Rebuild_Project.png icon and verify that the project builds successfully.



Next Step >

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