Practical Audio Experiments using the TMS320C5505 USB Stick

“Improved Audio Template”
Texas Instruments University Programme Teaching Materials

© 2010 Texas Instruments Inc

0-1

Improved Audio Template

© 2010 Texas Instruments Inc

Chapter 2 - Slide 2

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.

© 2010 Texas Instruments Inc

Chapter 2 - Slide 3

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.

© 2010 Texas Instruments Inc

Chapter 2 - Slide 4

• How to change the sampling rate and audio gain of the coder-decoder (CODEC) • How to use decibels. © 2010 Texas Instruments Inc Chapter 2 .Slide 5 .What you will Learn • How to read TI datasheets and use the values to configure registers.

Setting up the Codec © 2010 Texas Instruments Inc Chapter 2 .Slide 6 .

Slide 7 .USB Stick Codec Codec 12 MHz Crystal © 2010 Texas Instruments Inc Chapter 2 .

© 2010 Texas Instruments Inc Chapter 2 .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.Slide 8 .

Slide 9 .Codec Adjustments • The following can be adjusted on the codec: – Sampling rate – Input ADC gain – Output DAC gain. © 2010 Texas Instruments Inc Chapter 2 .

• This is the really useful part of the document! © 2010 Texas Instruments Inc Chapter 2 .Slide 10 .Phase Locked Loop (PLL) Setup • Table 5-25 PLL gives example configurations.

• This phase lock loop (PLL) has: – a fixed oscillator on the outside (12 MHz) – lower speed operation on the inside (e.Slide 11 . 48 kHz).Registers • All the fields PLLP. © 2010 Texas Instruments Inc Chapter 2 .g. PLLR etc refer to specific registers inside the Codec.

Slide 12 . © 2010 Texas Instruments Inc Chapter 2 .Clock Distribution Tree • The clock signals form a tree.

PLL Loop Clock Setups • The Phase Locked Loop frequency is calculated as follows: © 2010 Texas Instruments Inc Chapter 2 .Slide 13 .

Slide 14 . • The setup for 100 MHz is given in red.Master Clock (MCLK) • The TMS320C5505 USB Stick uses a 32768 Hz crystal for the Master Clock (MCLK). © 2010 Texas Instruments Inc Chapter 2 .

• Additional gain is required for these devices. © 2010 Texas Instruments Inc Chapter 2 .Setting the ADC Gain • Microphones and guitars have low electrical output.Slide 15 .

Slide 16 .Setting the ADC Gain • The ADC gain is controlled by Register 59 and Register 60: © 2010 Texas Instruments Inc Chapter 2 .

5 dB. • This also solves the problem of expressing 0.Range of Gain Values • The TLV320AIC3204 supports gains between 0 dB and 47.5 dB using fixed-point maths.Slide 17 . • In practical terms. intervals of 1 dB are perfectly adequate. © 2010 Texas Instruments Inc Chapter 2 .

Slide 18 . • A decibel is a ratio. Gain in dB  20 log ( Input 10 Reference ) © 2010 Texas Instruments Inc Chapter 2 .Gain in Decibels • The gain is expressed in terms of decibels (dB).

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 © 2010 Texas Instruments Inc Chapter 2 .Slide 19 .

C Code Implementation © 2010 Texas Instruments Inc Chapter 2 .Slide 20 .

c set_sampling_frequency_and_gain().New Function • The following C code function has been added to AIC3204_init. // Gain in dB © 2010 Texas Instruments Inc Chapter 2 . • This function takes two parameters: – unsigned long SamplingFrequency. // Sampling frequency Hz – unsigned int ADCgain.Slide 21 .

© 2010 Texas Instruments Inc Chapter 2 .Sampling Frequencies • The sampling frequency can be any of the following: 48000 24000 16000 12000 9600 8000 6857 • The default is 48000 Hz.Slide 22 .

Slide 23 .g.g. • 0 => 0 dB e.ADC Gain • The ADCgain takes a value between 0 and 48. microphone input • 48 => 48 dB e. © 2010 Texas Instruments Inc Chapter 2 .g. low output microphone input. line input • 30 => 30 dB e.

New #define © 2010 Texas Instruments Inc Chapter 2 .Slide 24 .

c: AIC3204_rset(51.Slide 25 . // Enable MICBIAS © 2010 Texas Instruments Inc Chapter 2 . 0x40). • It is necessary to turn on the MICBIAS power supply • Add the following line to aic3204_init.Electret Microphone • The TMS320C5505 USB Stick supports electret microphones.

Slide 26 .c: #define SAMPLES_PER_SECOND 48000 #define GAIN_IN_dB 0 © 2010 Texas Instruments Inc Chapter 2 .Configuration Example • To configure the codec with: – Sampling frequency 48000 Hz – Gain 0dB • Use following #defines in main.

Slide 27 .New Program Descriptors © 2010 Texas Instruments Inc Chapter 2 .

so Step changes once every 20 seconds and flashes the XF LED.New Timed Steps • The TMS320C5505 has no switches. © 2010 Texas Instruments Inc Chapter 2 .Slide 28 .

Introduction to Laboratory © 2010 Texas Instruments Inc Chapter 2 .Slide 29 .

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. © 2010 Texas Instruments Inc Chapter 2 .Slide 30 .

Create New Project © 2010 Texas Instruments Inc Chapter 2 .Slide 31 .

Files Used in Project © 2010 Texas Instruments Inc Chapter 2 .Slide 32 .

Slide 33 .Line Setup TMS320C5505 USB Stick USB to PC CD Player or MP3 Player Headphones © 2010 Texas Instruments Inc Chapter 2 .

Console for Line Setup • Sampling frequency and Gain are shown in the Console window. © 2010 Texas Instruments Inc Chapter 2 .Slide 34 .

Slide 35 .Microphone Setup TMS320C5505 USB to PC Microphone Headphones © 2010 Texas Instruments Inc Chapter 2 .

c • Change lines containing SAMPLES_PER_SECOND and GAIN_IN_dB as shown below: © 2010 Texas Instruments Inc Chapter 2 .Microphone Setup in main.Slide 36 .

Console for Microphone Setup • New Sampling frequency and Gain are shown in the Console window.Slide 37 . © 2010 Texas Instruments Inc Chapter 2 .

Experiments © 2010 Texas Instruments Inc Chapter 2 .Slide 38 .

c: #define SAMPLES_PER_SECOND 24000L © 2010 Texas Instruments Inc Chapter 2 .c and LEDflasher.Slide 39 .Change Sampling Frequency • Try different values of sampling frequency by changing the number in both main.

Slide 40 .c: #define GAIN_IN_dB 25 © 2010 Texas Instruments Inc Chapter 2 .Change Gain • Try different values of gain by changing the number in main.

Programming Challenge • Add code for Step 4 in main.Slide 41 .c © 2010 Texas Instruments Inc Chapter 2 .

Using TI Datasheets © 2010 Texas Instruments Inc Chapter 2 .Slide 42 .

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

© 2010 Texas Instruments Inc Chapter 2 .Slide 44 .References • TLV320AIC3204 Stereo Codec Data Sheet SLOS62.