Chapter 2 Improved Audio Template
-
Upload
douglas-mangini -
Category
Documents
-
view
227 -
download
0
Transcript of Chapter 2 Improved Audio Template
-
7/28/2019 Chapter 2 Improved Audio Template
1/44
0 - 1
2010 Texas Instruments Inc
Practical Audio Experiments using the TMS320C5505 USB Stick
ImprovedAudio Template
Texas Instruments University Programme
Teaching Materials
-
7/28/2019 Chapter 2 Improved Audio Template
2/44
Chapter 2 - Slide 2 2010 Texas Instruments Inc
Improved Audio Template
-
7/28/2019 Chapter 2 Improved Audio Template
3/44
Chapter 2 - Slide 3 2010 Texas Instruments Inc
Introduction
The code in MyFirstProject had:
Fixed sampling rate of 48000 samples per second
Suitable for line inputs (CD, iPod) onlyNot suitable for microphones and electric guitars.
-
7/28/2019 Chapter 2 Improved Audio Template
4/44
Chapter 2 - Slide 4 2010 Texas Instruments Inc
Objectives
To design an Improved Audio Template with:
Sampling rate adjustable between 8000 samplesper second and 48000 samples per second
Adjustable gain suitable for:
line inputs (CD player, MP3 etc).
microphones
electric guitars.
-
7/28/2019 Chapter 2 Improved Audio Template
5/44
Chapter 2 - Slide 5 2010 Texas Instruments Inc
What you will Learn
How to read TI datasheets and use the values toconfigure registers.
How to change the sampling rate and audio gain ofthe coder-decoder (CODEC)
How to use decibels.
-
7/28/2019 Chapter 2 Improved Audio Template
6/44
Chapter 2 - Slide 6 2010 Texas Instruments Inc
Setting up the Codec
-
7/28/2019 Chapter 2 Improved Audio Template
7/44Chapter 2 - Slide 7 2010 Texas Instruments Inc
USB Stick Codec
Codec 12 MHz Crystal
-
7/28/2019 Chapter 2 Improved Audio Template
8/44Chapter 2 - Slide 8 2010 Texas Instruments Inc
Setting up the Codec
The TMS320C5505 USB Stick uses aTLV320AIC3204 Codec (coder-decoder).
The information required to configure this device is
contained in TI datasheet SLOS602A.
-
7/28/2019 Chapter 2 Improved Audio Template
9/44Chapter 2 - Slide 9 2010 Texas Instruments Inc
Codec Adjustments
The following can be adjusted on the codec:
Sampling rate
Input ADC gain
Output DAC gain.
-
7/28/2019 Chapter 2 Improved Audio Template
10/44Chapter 2 - Slide 10 2010 Texas Instruments Inc
Phase Locked Loop (PLL) Setup
Table 5-25 PLL gives example configurations.
This is the really useful part of the document!
-
7/28/2019 Chapter 2 Improved Audio Template
11/44Chapter 2 - Slide 11 2010 Texas Instruments Inc
Registers
All the fields PLLP, PLLR etc refer to specificregisters 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. 48kHz).
-
7/28/2019 Chapter 2 Improved Audio Template
12/44Chapter 2 - Slide 12 2010 Texas Instruments Inc
Clock Distribution Tree
The clocksignals form atree.
-
7/28/2019 Chapter 2 Improved Audio Template
13/44Chapter 2 - Slide 13 2010 Texas Instruments Inc
PLL Loop Clock Setups
The Phase Locked Loop frequency is calculated asfollows:
-
7/28/2019 Chapter 2 Improved Audio Template
14/44Chapter 2 - Slide 14 2010 Texas Instruments Inc
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.
-
7/28/2019 Chapter 2 Improved Audio Template
15/44Chapter 2 - Slide 15 2010 Texas Instruments Inc
Setting the ADC Gain
Microphones and guitars have low electrical output.
Additional gain is required for these devices.
-
7/28/2019 Chapter 2 Improved Audio Template
16/44Chapter 2 - Slide 16 2010 Texas Instruments Inc
Setting the ADC Gain
The ADC gain is controlled by Register 59 andRegister 60:
-
7/28/2019 Chapter 2 Improved Audio Template
17/44
Chapter 2 - Slide 17 2010 Texas Instruments Inc
Range of Gain Values
The TLV320AIC3204 supports gains between 0 dBand 47.5 dB.
In practical terms, intervals of 1 dB are perfectlyadequate.
This also solves the problem of expressing 0.5 dBusing fixed-point maths.
-
7/28/2019 Chapter 2 Improved Audio Template
18/44
Chapter 2 - Slide 18 2010 Texas Instruments Inc
Gain in Decibels
The gain is expressed in terms of decibels (dB).
A decibel is a ratio.
)(log20dBinGainReference
Input
10
-
7/28/2019 Chapter 2 Improved Audio Template
19/44
Chapter 2 - Slide 19 2010 Texas Instruments Inc
Useful Decibels
The following are decibel values and their ratioequivalents:
0 dB => 1:1
6 dB => 2:1
20 dB => 10:1
40 dB => 100:1
60 dB => 1000:1
-
7/28/2019 Chapter 2 Improved Audio Template
20/44
Chapter 2 - Slide 20 2010 Texas Instruments Inc
C Code Implementation
-
7/28/2019 Chapter 2 Improved Audio Template
21/44
Chapter 2 - Slide 21 2010 Texas Instruments Inc
New Function
The following C code function has been added toAIC3204_init.c
set_sampling_frequency_and_gain();
This function takes two parameters: unsigned long SamplingFrequency; // Sampling
frequency Hz
unsigned int ADCgain; // Gain in dB
-
7/28/2019 Chapter 2 Improved Audio Template
22/44
Chapter 2 - Slide 22 2010 Texas Instruments Inc
Sampling Frequencies
The sampling frequency can be any of the following:
48000
24000
16000
12000
9600
8000
6857
The default is 48000 Hz.
-
7/28/2019 Chapter 2 Improved Audio Template
23/44
-
7/28/2019 Chapter 2 Improved Audio Template
24/44
Chapter 2 - Slide 24 2010 Texas Instruments Inc
New #define
-
7/28/2019 Chapter 2 Improved Audio Template
25/44
Chapter 2 - Slide 25 2010 Texas Instruments Inc
Electret Microphone
The TMS320C5505 USB Stick supports electretmicrophones.
It is necessary to turn on the MICBIAS power supply
Add the following line to aic3204_init.c:
AIC3204_rset(51, 0x40); // Enable MICBIAS
-
7/28/2019 Chapter 2 Improved Audio Template
26/44
Chapter 2 - Slide 26 2010 Texas Instruments Inc
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
-
7/28/2019 Chapter 2 Improved Audio Template
27/44
Chapter 2 - Slide 27 2010 Texas Instruments Inc
New Program Descriptors
-
7/28/2019 Chapter 2 Improved Audio Template
28/44
Chapter 2 - Slide 28 2010 Texas Instruments Inc
New Timed Steps
The TMS320C5505 has no switches, so Step changesonce every 20 seconds and flashes the XF LED.
-
7/28/2019 Chapter 2 Improved Audio Template
29/44
Chapter 2 - Slide 29 2010 Texas Instruments Inc
Introduction to Laboratory
-
7/28/2019 Chapter 2 Improved Audio Template
30/44
Chapter 2 - Slide 30 2010 Texas Instruments Inc
Installing the Application
Use the code given in Application 2 ImprovedAudio Template
Follow the steps previously given in Chapter 1 to
set up the new project.
-
7/28/2019 Chapter 2 Improved Audio Template
31/44
Chapter 2 - Slide 31 2010 Texas Instruments Inc
Create New Project
-
7/28/2019 Chapter 2 Improved Audio Template
32/44
Chapter 2 - Slide 32 2010 Texas Instruments Inc
Files Used in Project
-
7/28/2019 Chapter 2 Improved Audio Template
33/44
Chapter 2 - Slide 33 2010 Texas Instruments Inc
Line Setup TMS320C5505
USB to PC
Headphones
CD Player orMP3 Player
USB Stick
-
7/28/2019 Chapter 2 Improved Audio Template
34/44
Chapter 2 - Slide 34 2010 Texas Instruments Inc
Console for Line Setup
Sampling frequency and Gain are shown in theConsole window.
-
7/28/2019 Chapter 2 Improved Audio Template
35/44
Chapter 2 - Slide 35 2010 Texas Instruments Inc
Microphone Setup TMS320C5505
USB to PC
Headphones
Microphone
-
7/28/2019 Chapter 2 Improved Audio Template
36/44
Chapter 2 - Slide 36 2010 Texas Instruments Inc
Microphone Setup inmain.c
Change lines containing SAMPLES_PER_SECOND andGAIN_IN_dB as shown below:
-
7/28/2019 Chapter 2 Improved Audio Template
37/44
Chapter 2 - Slide 37 2010 Texas Instruments Inc
Console for Microphone Setup
New Sampling frequency and Gain are shown in theConsole window.
-
7/28/2019 Chapter 2 Improved Audio Template
38/44
Chapter 2 - Slide 38 2010 Texas Instruments Inc
Experiments
-
7/28/2019 Chapter 2 Improved Audio Template
39/44
Chapter 2 - Slide 39 2010 Texas Instruments Inc
Change Sampling Frequency
Try different values of sampling frequency bychanging the number in both main.c andLEDflasher.c:
#define SAMPLES_PER_SECOND 24000L
-
7/28/2019 Chapter 2 Improved Audio Template
40/44
Chapter 2 - Slide 40 2010 Texas Instruments Inc
Change Gain
Try different values of gain by changing thenumber in main.c:
#define GAIN_IN_dB 25
-
7/28/2019 Chapter 2 Improved Audio Template
41/44
Chapter 2 - Slide 41 2010 Texas Instruments Inc
Programming Challenge
Add code for Step 4 in main.c
-
7/28/2019 Chapter 2 Improved Audio Template
42/44
Chapter 2 - Slide 42 2010 Texas Instruments Inc
Using TI Datasheets
-
7/28/2019 Chapter 2 Improved Audio Template
43/44
Chapter 2 - Slide 43 2010 Texas Instruments Inc
Using TI Datasheets
The datasheet for the TLV320AIC3204 Codec hasthe TI literature number SLOS62A.
The last letter A is the revision number, which may
change.
Therefore, when searching for the latest version ofthe above document on the TI website, just enterSLOS62.
-
7/28/2019 Chapter 2 Improved Audio Template
44/44
References
TLV320AIC3204 Stereo Codec Data Sheet SLOS62.