A new feature introduced in the AVR® DB family of microcontrollers (MCUs) is the Analog Signal Conditioning (OPAMP) peripheral. In this example, the OPAMP peripheral is used to amplify a weak signal up to the 100-millivolt range so that it can be detected by an analog comparator in the MCU or converted to a digital signal by the MCU’s analog-to-digital converter (ADC). Up to three internal op amps are available for configuration in the AVR DB. The configuration for this example can be seen in the figure above. Including the MCU the setup uses an external electret microphone, a resistor, and a capacitor. For more information about setup and code, see the application note.
- AN3631 - Low-BOM Microphone Interface Using the Analog Signal Conditioning (OPAMP) Peripheral
- AVR128DB48 Curiosity Nano User Guide
- AVR128DB48 Device Page
- MPLAB® X IDE 5.50 or newer (http://www.microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.32 or a newer compiler (http://www.microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 4.1.0 or newer (https://www.microchip.com/mplab/mplab-code-configurator)
- MPLAB® Melody Library 1.84.2 or newer (https://www.microchip.com/mplab/mplab-code-configurator)
- MPLAB® Code Configurator (MCC) Device Libraries AVR® MCUs 2.70 or newer (https://www.microchip.com/mplab/mplab-code-configurator)
- Microchip AVR-Dx Series Device Support (1.8.112) or newer (https://packs.download.microchip.com/)
- AVR128DB48 Curiosity Nano
- Electret microphone
- One 2.2 kΩ resistor, R5
- One 1 µF capacitor, C1
This section describes how this example was configured in MCC.
- The OPAMP driver was found under Device Resources, and added
- The Builder tab showed the system, with the added OPAMP peripheral
- Clicked on the OPAMP block, to enable the OPAMP driver Easy View and configured as shown below
Note: System Gain is calculated based on settings from both OP0 and OP1, and the screenshot shows the calculated value once OP1 was setup, as shown below.
- Clicked on Generate in the Resource Management tab to generate the source code
- Connect the hardware together as shown in the schematic above:
- Electret microphone
- Resistor, R5
- Capacitor, C1
- Connect the AVR128DB48 Curiosity Nano to a computer using a USB cable
- Clone this repository or download the *.zip to get the source code
- Open the
avr128db48-low-bom-mic-interface-using-opamp-mplab-mcc.X
project in MPLAB X - Click Clean and Build to build the example
- Click Make and Program Device to run the example
- If no tool has been chosen, a window will open, select the AVR128DB48 Curiosity Nano evaluation kit. The tool can also be chosen in the project settings.
After going through this example, you should have a better understanding of how to set up the OPAMP peripheral to amplify weak signals from sensors into detectable signals for the MCU.