Skip to content

This example will demonstrate how to interface the MCP6022-Microphone on-board the Curiosity Nano Explorer development board using ADC protocol.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/pic18f56q24-curiosity-nano-explorer-mcp6022-microphone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microchip Technologies Inc.

Interfacing a microphone on the PIC18F56Q24 Curiosity Nano Explorer board

This example demonstrates how to interface with the MCP6022 microphone integrated on the Curiosity Nano Explorer development board by utilizing the Analog-to-Digital Converter (ADC) found on the PIC18F56Q24 microcontroller. The analog audio signals captured by the microphone are converted into a digital data representation the ADC on the PIC18F56Q24. This digital data is then transmitted from the PIC18F56Q24 to a host computer via the Universal Asynchronous Receiver and Transmitter (UART) interface. On the host computer, the Data Visualizer tool is used to display and analyze the incoming data in real time, allowing users to observe the microphone’s output and evaluate its performance.

Related Documentation

Software Used

Hardware Used

Curiosity Nano Explorer

Project Setup

All instructions required to recreate this example are provided below:

  • Create a new project and open the MPLAB Code Configurator (MCC) by selecting Tools > Embedded > MPLAB Code Configurator.
  • In the Resource Management tab, navigate to Device Resources > Libraries > Data Visualizer > Data Streamer. Click the '+' icon to add the Data Streamer to the project graph.

UART Configuration & Setup

  • The UART peripheral will be automatically added under Project Resources > Drivers. Select the UART peripheral to open its configuration panel.
  • Specify UART2 as the PLIB selector. Configure the settings in the configuration window to match the provided reference image.

UART Configuration

ADC Configuration & Setup

  • Navigate to Device Resources > Drivers > ADC and select the '+' icon to add the ADC peripheral to your project

  • Select ADC from Project Resources > Drivers > ADC to open the configuration window

  • See images below for changes that must be made. Note that:

    • In image 1, continuous operation is enabled. This means that sampling will start automatically once a conversion is complete.
    • In image 2, the sampling frequency is approximately 48 kHz, the standard rate for microphones. You can adjust the sampling frequency by adjusting the clock divider.
    • In image 3, the conversion interrupt is enabled. The main program will contain an interrupt service routine (ISR) that writes the conversion result to the Data Visualizer.
  • Navigate to Device Resources > Drivers > ADC and click the '+' icon to add the ADC peripheral to the project.

  • Select ADC from Project Resources > Drivers > ADC to open the configuration window.

  • Refer to the images below for the required configuration changes. Note the following:

    • In image 1, continuous operation is enabled, allowing sampling to start automatically after each conversion is complete.
    • In image 2, the sampling frequency is set to approximately 48 kHz, which is the standard rate for microphones. The sampling frequency can be adjusted by modifying the clock divider.
    • In image 3, the conversion interrupt is enabled. The main program will include an interrupt service routine (ISR) that writes the conversion result to the Data Visualizer.

    ADC Configuration 1

    ADC Configuration 2

    ADC Configuration 3

Pin Configuration & Setup

  • The userguide for the Curiosity Explorer Nano board provides detailed information about the pin mapping between the Curiosity Explorer board and the PIC18F56Q24 Curiosity Nano board being used in this example. This example uses the ADC and UART peripherals found on the PIC18F56Q24. According to the image below, RB5 and RB4 are assigned as UART2 TX and RX, respectively. On the physical Curiosity Nano Explorer board, the "Microphone out" signal is connected to ADC6, which corresponds to pin RA3.

Curiosity Nano Pin Mapping

  • To select and configure these pins in MPLAB Code Configurator (MCC), open the "Pin Grid View" located in the lower half of the interface. Adjust the pin assignments to match the configuration shown in the image below.

MCC Pin Grid View

  • Click on "Generate" to complete the configuration in MCC.

Operation

After programming the device, open the Data Visualizer by selecting the "DV" icon from the toolbar.

  • In the Data Visualizer, select "Variable Streamer" from the sidebar, then click "Import."
  • Navigate to mcc_generated_files > data_streamer and select the data_streamer.ds file.
  • Specify the Curiosity Nano as the data source, then select the plot data icon to begin visualizing the data.
  • To adjust the graph axes, hover over the desired axis and use the scroll wheel to zoom in or out. Click and drag the axis to reposition it as needed.

Data Visualizer Output

For more information on using the Data Streamer, navigate to the official online documentation. or support resources provided by the development environment or tool vendor.

Summary

This demonstration shows how to configure the ADC on the PIC18F56Q24 microcontroller. To simulate a practical application, an analog signal is captured from a microphone, and the resulting data is displayed using the Data Visualizer tool.

About

This example will demonstrate how to interface the MCP6022-Microphone on-board the Curiosity Nano Explorer development board using ADC protocol.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •