Sie sind auf Seite 1von 44

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

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 5

Setting up the Codec

2010 Texas Instruments Inc

Chapter 2 - Slide 6

USB Stick Codec


Codec 12 MHz Crystal

2010 Texas Instruments Inc

Chapter 2 - Slide 7

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 8

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

2010 Texas Instruments Inc

Chapter 2 - Slide 9

Phase Locked Loop (PLL) Setup


Table 5-25 PLL gives example configurations. This is the really useful part of the document!

2010 Texas Instruments Inc

Chapter 2 - Slide 10

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

2010 Texas Instruments Inc

Chapter 2 - Slide 11

Clock Distribution Tree


The clock signals form a tree.

2010 Texas Instruments Inc

Chapter 2 - Slide 12

PLL Loop Clock Setups


The Phase Locked Loop frequency is calculated as follows:

2010 Texas Instruments Inc

Chapter 2 - Slide 13

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 14

Setting the ADC Gain

Microphones and guitars have low electrical output. Additional gain is required for these devices.

2010 Texas Instruments Inc

Chapter 2 - Slide 15

Setting the ADC Gain


The ADC gain is controlled by Register 59 and Register 60:

2010 Texas Instruments Inc

Chapter 2 - Slide 16

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 17

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

Gain in dB 20 log (

Input 10 Reference

2010 Texas Instruments Inc

Chapter 2 - Slide 18

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

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

2010 Texas Instruments Inc

Chapter 2 - Slide 21

Sampling Frequencies
The sampling frequency can be any of the following:
48000 24000 16000 12000 9600 8000 6857

The default is 48000 Hz.


2010 Texas Instruments Inc

Chapter 2 - Slide 22

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 23

New #define

2010 Texas Instruments Inc

Chapter 2 - Slide 24

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

2010 Texas Instruments Inc

Chapter 2 - Slide 25

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

2010 Texas Instruments Inc

Chapter 2 - Slide 26

New Program Descriptors

2010 Texas Instruments Inc

Chapter 2 - Slide 27

New Timed Steps


The TMS320C5505 has no switches, so Step changes once every 20 seconds and flashes the XF LED.

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

Line Setup TMS320C5505


USB Stick

USB to PC
CD Player or MP3 Player Headphones

2010 Texas Instruments Inc

Chapter 2 - Slide 33

Console for Line Setup


Sampling frequency and Gain are shown in the Console window.

2010 Texas Instruments Inc

Chapter 2 - Slide 34

Microphone Setup TMS320C5505


USB to PC
Microphone Headphones

2010 Texas Instruments Inc

Chapter 2 - Slide 35

Microphone Setup in main.c


Change lines containing SAMPLES_PER_SECOND and GAIN_IN_dB as shown below:

2010 Texas Instruments Inc

Chapter 2 - Slide 36

Console for Microphone Setup


New Sampling frequency and Gain are shown in the Console window.

2010 Texas Instruments Inc

Chapter 2 - Slide 37

Experiments

2010 Texas Instruments Inc

Chapter 2 - Slide 38

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

2010 Texas Instruments Inc

Chapter 2 - Slide 39

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

2010 Texas Instruments Inc

Chapter 2 - Slide 40

Programming Challenge
Add code for Step 4 in main.c

2010 Texas Instruments Inc

Chapter 2 - Slide 41

Using TI Datasheets

2010 Texas Instruments Inc

Chapter 2 - Slide 42

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.

2010 Texas Instruments Inc

Chapter 2 - Slide 43

References

TLV320AIC3204 Stereo Codec Data Sheet SLOS62.

2010 Texas Instruments Inc

Chapter 2 - Slide 44