Advanced Software Framework (ASF) Audio Sine Tone Tutorial

 Objective

The Advanced Software Framework (ASF) is a collection of embedded software for Atmel flash microcontrollers. It simplifies the usage of microcontrollers, providing an abstraction to the hardware and middleware. It is designed to be used for evaluation, prototyping, design and production phases. ASF is integrated into Atmel Studio IDE.

This tutorial shows you how to use the ASF to create an Audio Sine Tone application running on the SAM V71 Xplained Ultra Evaluation Kit.

Two Ways to Use This Tutorial

  1. Create the project from scratch
    • Use the provided source files and follow the step-by-step instructions given below.
  2. Use the solution project as an example
    • Just build the solution project and download it to the SAM V71 Xplained Ultra Evaluation Kit to observe the expected behavior.

Lab Objectives

  1. Create an Atmel Studio project from scratch for SAM V71 microcontroller.
  2. Use the ASF Wizard to select the ASF modules (driver(s)/component(s)/service(s)) to be used by the application.
  3. Setup the board, clock, and serial interface configuration.
  4. Add code to configure the SSC(I2S) and XDMAC(DMA) peripherals and the WM8904 audio codec.
  5. Add code to initialize the application and generate the sine tone.
  6. Demonstrate the use of ASF modules (services and drivers) to control SAM V71 peripherals (SSC, TWI, USART, Timers etc.).

 Materials

Hardware Tools

SAM V71 Xplained Ultra Evaluation Kit

The Xplained Ultra series evaluation kits include an onboard Embedded Debugger (EDBG), and no external tools are necessary to program or debug the ATSAMV71Q21. The EDBG connects to the host PC through the USB Micro-B connector on the SAM V71 Xplained Ultra Evaluation Kit for programming/debugging.

Apart from the hardware tools listed above, the following items are required to hear the audio playback:

  • Wired Stereo headphone
  • USB Type A male to micro-B male cable for programming/debugging
samv71_xult.jpg

Software Tools

This project has been verified to work with the following versions of software tools:
Atmel Studio 7 (Version: 7.0.1188), ARM/GNU C Compiler : 5.3.1, ASF v3.32.0

Because we regularly update our tools, occasionally you may discover an issue while using newer versions. If you suspect that to be the case, we recommend that you double-check using the same versions that the project was tested with.

Archived versions of our tools can be found on the following Microchip websites:
Atmel Studio 7

Note that you don't need to separately install the IDE, ARM GCC Compiler, and ASF. Installing Atmel Studio will install the IDE, supported ARM GCC compiler and ASF.

Tool About Installers
Installation
Instructions
Windows Linux Mac OSX
swtool-28px.png
Atmel® Studio
Integrated Development Environment

Overview:

This lab enables the SAM V71 Xplained Ultra Evaluation Kit to act as an audio speaker by playing the sine tone data (sampling rate: 48 kHz, 16-bit data), stored in a lookup table in internal memory. This is done by adding SSC, XDMAC, and codec driver libraries to the project.

  • SSC (Synchronous Serial Controller) is a serial synchronous communication module available on Microchip’s 32-bit Arm® Cortex®-M3, Cortex-M4 and Cortex-M7 series of microcontrollers. SSC supports multiple synchronous communication protocols generally used in audio and telecom applications such as I2S (Inter-IC Sound), Short Frame Sync, Long Frame Sync, etc. In this application, SSC is used to interface with audio codec WM8904 over I2S protocol.
  • XDMAC (Extensible DMA Controller) performs peripheral data transfer and memory move operations over one or two bus ports through the unidirectional communication channel.

Figure 1.1 Application Flow Sequence
  • Configure Clock and Board: Functions sysclk_init and board_init initialize SAM system clock and board configurations.
  • Configure Console: The function configure_console initializes the debug console interface (USART).
  • Configure codec: The function configure_codec configures the codec WM8904 in master or slave mode.
  • Configure SSC: The function configure_ssc configures the SSC peripheral for transmission of audio data in I2S mode acting as a master or slave.
  • Configure XDMAC: The function configure_xdma sets up the transfer through XDMAC peripheral by configuring XDMAC peripheral in linked list mode.
  • Enable Reference Clock: The PMC functions pmc_pck_set_prescaler, pmc_pck_set_source and pmc_enable_pck enable the reference clock to the codec WM8904.
  • Start Audio playback: The functions ssc_enable_tx and xdmac_channel_enable start the audio tone playback.
fig_1_flowchart.png
Click image to enlarge.
Figure 1.1 shows the flow sequence of the application task.
Click image to enlarge.

Lab Source Files and Solutions:

This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab as per the following step-by-step instructions (see the "Procedure" section on this page).

The contents of this ZIP file can be placed in a folder of your choice, preferably in a top level folder of a drive.


Extracting the ZIP file will create the following folders:

  • audio_sine_tone contains the lab folder audio_sine_tone_lab
  • audio_sine_tone_lab contains the complete lab solution (audio_sine_tone_lab.atsln and related files under sub folder audio_sine_tone_lab) and source files (in the dev_files folder) to create the lab from scratch.
  • dev_files contains application source files and other support files (if any) required to perform the lab from scratch (see Procedure section below).
  • audio_sine_tone_lab.atsln is the completed lab solution project. It can be directly built and downloaded on the hardware to observe expected behavior.

Procedure:

All steps must be completed before you will be ready to build, download, and run the application.

Lab Index

Step 1: Create a Project for SAM V71 Microcontroller

  • Step 1.1 – Create an ASF Project Using Atmel Studio IDE

Step 2: Use the ASF Wizard to Select the ASF Driver(s)/Component(s)/Service(s)

  • Step 2.1 - Add SSC, XDMAC and stdio Drivers
  • Step 2.2 - Add System Clock Control and Delay Routines Services
  • Step 2.3 - Add Audio Codec WM8904 Component
  • Step 2.4 - Verify the Added Modules

Step 3: Setup the Board, Clock, and Serial Interface Configuration

  • Step 3.1 - Customize Board Configuration
  • Step 3.2 - Customize Clock Configuration
  • Step 3.3 - Customize Serial Interface Configuration

Step 4: Add Code to Configure the SSC and XDMAC Peripherals and the WM8904 Audio Codec

  • Step 4.1 - Replace main.c with audio_sine_tone.c
  • Step 4.2 - Implement SSC Configuration
  • Step 4.3 - Implement XDMAC Configuration
  • Step 4.4 - Implement Audio Codec WM8904 Configuration

Step 5: Add Code to Initialize the Application and Generate the Audio Sine Tone
Step 6: Debug Your Application

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.