1 / 44

“Improved Audio Template”

“Improved Audio Template”. Texas Instruments University Programme Teaching Materials. Improved Audio Template. Introduction. The code in MyFirstProject had: Fixed sampling rate of 48000 samples per second Suitable for line inputs (CD, iPod) only

lemuel
Download Presentation

“Improved Audio Template”

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. “Improved Audio Template” Texas Instruments University Programme Teaching Materials

  2. Improved Audio Template

  3. Introduction • The code in MyFirstProject had: • Fixed sampling rate of 48000 samples per second • Suitable for line inputs (CD, iPod) only • Not suitable for microphones and electric guitars.

  4. Objectives • To design an Improved Audio Template with: • Sampling rate adjustable between 8000 samples per second and 48000 samples per second • Adjustable gain suitable for: • line inputs (CD player, MP3 etc). • microphones • electric guitars.

  5. What you will Learn • How to read TI datasheets and use the values to configure registers. • How to change the sampling rate and audio gain of the coder-decoder (CODEC) • How to use decibels.

  6. Setting up the Codec

  7. USB Stick Codec Codec 12 MHz Crystal

  8. Setting up the Codec • The TMS320C5505 USB Stick uses a TLV320AIC3204 Codec (coder-decoder). • The information required to configure this device is contained in TI datasheet SLOS602A.

  9. Codec Adjustments • The following can be adjusted on the codec: • Sampling rate • Input ADC gain • Output DAC gain.

  10. Phase Locked Loop (PLL) Setup • Table 5-25 PLL gives example configurations. • This is the really useful part of the document!

  11. Registers • All the fields PLLP, PLLR etc refer to specific registers inside the Codec. • This phase lock loop (PLL) has: • a fixed oscillator on the outside (12 MHz) • lower speed operation on the inside (e.g. 48 kHz).

  12. Clock Distribution Tree • The clock signals form a tree.

  13. PLL Loop Clock Setups • The Phase Locked Loop frequency is calculated as follows:

  14. Master Clock (MCLK) • The TMS320C5505 USB Stick uses a 32768 Hz crystal for the Master Clock (MCLK). • The setup for 100 MHz is given in red.

  15. Setting the ADC Gain • Microphones and guitars have low electrical output. • Additional gain is required for these devices.

  16. Setting the ADC Gain • The ADC gain is controlled by Register 59 and Register 60:

  17. Range of Gain Values • The TLV320AIC3204 supports gains between 0 dB and 47.5 dB. • In practical terms, intervals of 1 dB are perfectly adequate. • This also solves the problem of expressing 0.5 dB using fixed-point maths.

  18. Gain in Decibels • The gain is expressed in terms of decibels (dB). • A decibel is a ratio.

  19. Useful Decibels • The following are decibel values and their ratio equivalents: • 0 dB => 1:1 • 6 dB => 2:1 • 20 dB => 10:1 • 40 dB => 100:1 • 60 dB => 1000:1

  20. C Code Implementation

  21. New Function • The following C code function has been added to AIC3204_init.c set_sampling_frequency_and_gain(); • This function takes two parameters: • unsigned long SamplingFrequency; // Sampling frequency Hz • unsigned int ADCgain; // Gain in dB

  22. Sampling Frequencies • The sampling frequency can be any of the following: 48000 24000 16000 12000 9600 8000 6857 • The default is 48000 Hz.

  23. ADC Gain • The ADCgain takes a value between 0 and 48. • 0 => 0 dB e.g. line input • 30 => 30 dB e.g. microphone input • 48 => 48 dB e.g. low output microphone input.

  24. New #define

  25. Electret Microphone • The TMS320C5505 USB Stick supports electret microphones. • It is necessary to turn on the MICBIAS power supply • Add the following line to aic3204_init.c: AIC3204_rset(51, 0x40); // Enable MICBIAS

  26. Configuration Example • To configure the codec with: • Sampling frequency 48000 Hz • Gain 0dB • Use following #defines in main.c: #define SAMPLES_PER_SECOND 48000 #define GAIN_IN_dB 0

  27. New Program Descriptors

  28. New Timed Steps • The TMS320C5505 has no switches, so Step changes once every 20 seconds and flashes the XF LED.

  29. Introduction to Laboratory

  30. Installing the Application • Use the code given in Application 2 Improved Audio Template • Follow the steps previously given in Chapter 1 to set up the new project.

  31. Create New Project

  32. Files Used in Project

  33. Line Setup TMS320C5505 USB Stick USB to PC CD Player or MP3 Player Headphones

  34. Console for Line Setup • Sampling frequency and Gain are shown in the Console window.

  35. Microphone Setup TMS320C5505 USB to PC Microphone Headphones

  36. Microphone Setup in main.c • Change lines containing SAMPLES_PER_SECOND and GAIN_IN_dB as shown below:

  37. Console for Microphone Setup • New Sampling frequency and Gain are shown in the Console window.

  38. Experiments

  39. Change Sampling Frequency • Try different values of sampling frequency by changing the number in both main.c and LEDflasher.c: #define SAMPLES_PER_SECOND 24000L

  40. Change Gain • Try different values of gain by changing the number in main.c: #define GAIN_IN_dB 25

  41. Programming Challenge • Add code for Step 4 in main.c

  42. Using TI Datasheets

  43. Using TI Datasheets • The datasheet for the TLV320AIC3204 Codec has the TI literature number SLOS62A. • The last letter A is the revision number, which may change. • Therefore, when searching for the latest version of the above document on the TI website, just enter SLOS62.

  44. References • TLV320AIC3204 Stereo Codec Data Sheet SLOS62.

More Related