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

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

Configure the Audio Codec AK4953, I²C Driver, and I²S Driver

Select the MPLAB® Harmony Configurator (MHC) Project Graph tab. Remember, if you ever lose the MHC Tool, you can find it by selecting Tools > Embedded > MPLAB Harmony 3 Configurator.

MHC Project Graph tab.​​​

If you can select an AK4953 driver, skip to the next step.

If there is no AK4953 driver selection, you are probably using an MHC audio version before this support was added (audio 3.4.0 or before). You can add the driver manually by copying the following files from your downloaded ZIP file contained in the audio_player/audio folder.
Copy audio_player/audio/driver/codec/AK4953 to <Harmony install path>/audio/driver/codec/.
Copy audio_player/audio/templates/ak4953 to <Harmony install path>/audio/templates/.
Modify the <Harmony install path>/audio/driver/config/module.py file to add the entry for the AK4953 driver.

component = Module.CreateComponent("audio_codec_ak4953", "AK4953", "/Audio/Drivers/Codec/", "codec/AK4953/config/ak4953.py")
component.setDisplayType("Driver")
component.addDependency("DRV_I2C", "DRV_I2C", False)
component.addDependency("DRV_I2S", "DRV_I2S", False)
component.addCapability("audio_codec", "Audio Codec", False)

AK4953 driver

Restart MHC.


Configure the AK4953 driver component.

The AK4953 component block will be displayed in the Project Graph window.

AK4953 component block displayed in the Project Graph window

You can move component blocks around in the Project Graph by clicking on them and dragging them around.

Highlight the component block by clicking on it. The available configuration setting will be displayed in the Configuration Options window. For this project, keep the default settings.

List of Satisfiers


Attach an I²C driver to the AK4953 component block.

Right-click on the yellow diamond next to DRV_I2C to bring up a list of Satisfiers that can be used to attach to this component. Select the I²C driver component by clicking on it.

List of Satisfiers

At this point, you will be asked to auto-activate some components required by the system. Select Yes for the core component and No for the FreeRTOS component.

Auto-activate Dialog box

Don't worry if you make a mistake. You can delete components that you inadvertently add. Click on the component in the Project Graph and then click on the red X. You can also add items from the Available Components window, such as the Core component.

Your Project Graph should now resemble the accompanying figure.

Project Graph

Configure the Core options by clicking on the Core component block. This will bring up the Core option selections in the Configuration Options window. Ensure that the blocks for Enable System Ports and Enable System DMA are checked.

Core component block


Attach an I²C peripheral (PLIB) to your I²C driver.

Right-click on the diamond for the I2C Instance 0. From the Satisfiers list, select I2C2. This matches the hardware I²C peripheral that is routed to the AK4953 controller on the MEB-II Expansion Card.

Select I2C2 from Satisfiers list

Your Project Graph should now resemble the accompanying figure.

Project Graph

Click on the I2C2 peripheral to display the Configuration Options available for this component. Check the option to Include Force Write I2C Function(Master Mode Only - Ignore NACK from Slave). This option is required because of the way the AK4953 controller has implemented the I²C protocol.

Configuration Options Available for this Component


Attach an I²S driver to the AK4953 component block.

Similar to the I²C, right-click on the yellow diamond next to DRV_I2S to bring up a list of Satisfiers that can be used to attach to this component. Select the I²S driver component by clicking on it. The resulting screen is shown.

Satisfiers List for this Component


Attach an I²S peripheral (PLIB) to your I²S driver.

Right-click on the diamond for the I2S Instance 0. From the Satisfiers list, select I2S1. This matches the hardware I²S peripheral that is routed to the AK4953 controller on the MEB-II Expansion Card. The resulting screen is shown.

Satisfiers list, select I2S1

Click on the I2S1 peripheral to display the Configuration Options available for this component. Change the Frame Select Pin to F12 (which is used by the MEB-II hardware).

Change the Frame Select Pin to F12 in Component Options


Add the Time system service component.

Expand the Available Components window for Harmony > System Services and select the TIME component.

Available Components Window

Your Project Graph should now resemble the accompanying figure.

Project Graph


Attach the CORE TIMER to the Time system service.

Right-click on the TMR diamond in the Time system service block. Select CORE TIMER from the Satisfiers list.

Select CORE TIMER from the Satisfiers list​​

Your Project Graph should now resemble the accompanying figure.

Project Graph


Save the MHC configuration by clicking the Save button.