Audio-Tone Generation Using a Lookup Table With MPLAB® Harmony v3: Step 6
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.
If you can select an AK4953 driver, skip to the next step.
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)
Restart MHC.
Configure the AK4953 driver component.
The AK4953 component block will be displayed in the Project Graph window.
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.
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.
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.
Your Project Graph should now resemble the accompanying figure.
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.
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.
Your Project Graph should now resemble the accompanying figure.
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.
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.
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.
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).
Add the Time system service component.
Expand the Available Components window for Harmony > System Services and select the TIME component.
Your Project Graph should now resemble the accompanying figure.
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.
Your Project Graph should now resemble the accompanying figure.