Audio-Tone Generation Using a Lookup Table With MPLAB® Harmony v3: Step 7

Last modified by Microchip on 2023/11/09 09:07

Generate Harmony Code and Build Project

Expand the source file folders in the Projects pane. Notice how there are no source files at all, just an empty project with the correct Harmony structure.

Source file folders view​​​​

Back to Top


Click on the Generate Code button as shown in the following figure. Notice the Merging Strategy option.

Click on the generate code button

Let’s examine what was done after generating code:

The app folder contains files related to your specific application. In the following steps, you will add your own code to the existing app.c and app.h files You will also add other application-specific source files.

The framework folder under the app folder contains customized Harmony Framework files. These files have been generated by the MHC in response to your specific MHC selections.

Also, note the config folder under the Source Files folder contains standard Harmony Framework files that have been added to your project by the MHC (based on your MHC selections). To be clear, unlike the framework files found under the app folder, these files have not been modified by the MHC. They are some of the standard Harmony Framework files included in the Harmony Framework download.

App folder tree view

Back to Top


Check for Harmony 3 issues in previously released versions.​

In previously released versions of the Harmony 3 audio code (audio 3.4.0 and before), there was an issue with the I²S driver that needs to be resolved in the source file drv_i2s.c. This only needs to be done if you are using a PIC32 type processor. The directory structure shows the location of this file which gets generated by MHC.

drv_i2s.c file shown in the source files

In the source file drv_i2s.c make sure the buffer size is not getting divided down into a word count. Search for all "/= 2" occurrences and comment them out (refer to accompanying code). This occurs five different times in the following functions; _DRV_I2S_BufferQueueTask (occurs twice), DRV_I2S_WriteBufferAddDRV_I2S_WriteReadBufferAdd, and DRV_I2S_ReadBufferAdd.

Code modification example

If you do need to modify these lines, the next time you generate code, you will see the following merge screens displayed. Just press the Close button.

Merge screens display

Back to Top


Save all files and build the code. To do this, click on the Clean and Build icon Clean and build icon and verify the project builds successfully.

At this point, you should be able to debug and step through the application. Effectively, you have a running MPLAB Harmony system. However, it is not yet ready to do anything. Next, you will develop your application state machine logic and make sure the system does what you want it to do. You’re ready to start implementing the application now.

Back to Top