Step 6: Debug your Application
Congratulations! You are ready to DEBUG 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.
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
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.