Audio Sine Tone Tutorial: Step 6


< Back to Lab Start

Step 6: Debug your Application

Congratulations! You are ready to DEBUG image47.png the application!

1

Connect a USB cable from the micro USB connector (Debug USB) on the SAM V71 Xplained Ultra Evaluation Kit to the PC.

2

Connect a headphone to the HEADPHONE connecter on the SAM V71 Xplained Ultra Evaluation Kit.

3

Before you start the debugger, you may want to set breakpoints in the application file audio_sine_tone.c to verify that important stages of the application are executed successfully.

4

Put a breakpoint in the main function to check whether the following functions have been executed successfully:

  • wm8904_twi_init has initialized the Codec WM8904 interface
  • configure_codec has configured the Codec WM8904
  • configure_ssc has configured SSC
  • configure_xdma has configured XDMA
image48.png

5

Next, put a breakpoint to verify that the PMC has setup and enabled the prescalar and clock source to the reference clock PCK2 successfully.

image49.png

You could also set a breakpoint in the if or else statement depending on the value of the macro PCK2. The default value of the macro PCK2 is set to PMC_MCKR_CSS_SLOW_CLK. Therefore set a breakpoint under the if statement.

6

Debug your application! Click the 'Debug Main Project' image47.png icon.

7

Verify that the application goes through the breakpoints previously set, and when the last breakpoint is hit, It means that the application is initialized and configured successfully, and is ready to run.

8

At this point, remove all break points. Reset and run the application.

9

Put on your headphone, and you should be able to hear the audio sine tone getting played.
You could also verify the analog sine signal on the headphone, values of bit clock BCLK and sampling rate clock LRCK by probing the corresponding pins on Xplained Ultra Board (Refer to the SAM V71 Xplained Ultra User Guide for details on the pins).

When the application is run with the SAM V71 as I2S master (By defining macro PCK2 as PMC_MCKR_CSS_MAIN_CLK), you could hear a slight audible static disturbance when the sine tone is
being played. This is because in master mode, the 12 MHz reference clock provided to the CODEC WM8904 is not an accurate clock (it should be 12.288 MHz) for the supported oversampling rates (64fs, 128fs, 192fs, 256fs, …).

 Results

You should be able to hear a sine tone output through the headphone jack on the SAM V71 Xplained Ultra Evaluation Kit. If you did not configure the SSC driver, XDMAC driver, CODEC driver or reference clock properly, you may not hear the audio at all or may hear distorted audio coming out with clicks and pops in the stream.

 Analysis

In this lab, you have successfully played a sine tone on the SAM V71 microcontroller and heard the audio through the headphone on the development board. The sine tone produced is 16-bit, at a 48000 sampling rate. The tone as such was produced statically and stored in the form of a lookup table in an array. ASF Wizard was used to add drivers for the hardware modules. The application was developed in a top-down implementation model. In the application, audio buffer management was done by using the linked list feature provided by the XDMAC peripheral.

 Conclusions

You have successfully developed a full-fledged ASF Application. This gives you a fair idea of how ASF helps in application development. If you need to add audio support to any of your existing applications, this lab can be used as a reference. This can also be a starting point for your audio intensive applications.

© 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.