Vous êtes sur la page 1sur 37

Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr.

Thuong Le-Tien

Vietnam National University HoChiMinh City


University of Technology

P . F . I . E . V

Digital Signal Processing


Project Report
AMPLITUDE MODULATION
USING TMS320C5515 eZdspTM USB
Stick
Assoc.Prof.Dr. Thuong Le-Tien
Huy Nguyen-Thanh 20901026 VP09VT
Group
Tuan Nguyen-Oanh 40903113 VP09VT
1
My Le-Duy 20901599 VP09NL
Khoa Nguyen-Tien 40901248 VP09NL

Ho Chi Minh City, May 2013


Project Report 1 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Project Report
AMPLITUDE MODULATION

USING TMS320C5515 eZdsp USB Stick

GROUP 1

Project Report 2 Group 1


Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Abstract
As early as the 1950s, designers of signal processing systems were using
digital computers to simulate and test their designs. It didn’t take too long to
realize that the digital algorithms developed to drive the simulations could be
used to carry out the signal processing directly – and so the digital signal
processor was born. With the incredible development of microprocessor chips
over the last decades, digital signal processing has become a hugely
important topic. Speech synthesis and recognition, image and music
enhancement, robot vision, pattern recognition, motor control, spectral
analysis, anti-skid braking and global positioning are just a few of the diverse
applications of digital signal processors.

This project aims to understand more thoroughly about DSP through


carrying out a simple digital signal process, videlicet Amplitude modulation
using TMS320C5515 eZdsp USB Stick. Moreover, this is a very good chance to
revise the knowledge learned from Analog and Digital Modulation and Digital
Signal Processing courses.

This report contains four main parts. Part one introduces the DSP course as
well as its applications in our life. Part two will talk about the MATLAB based
programs and their results. In part three, programs based on the hardware will
be shown beside their results. And the last part contains some comparisons
and conclusions in terms of signal processing.

Abstract 3 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Acknowledgements

The student group would like to thank Associate Professor Dr. Thuong Le-Tien
who officially taught us the theory of digital signal processing and helped us
approach a new horizon of knowledge. Moreover, he did not only support us the
study of hardware but also instructed us step-by-step whole heartedly to handle
potential problems.

Thanks also to the numerous authors whose documents we have referred to


carry out our project.

Finally, special thanks to our families for their unstinting encouragement and
support.

Acknowledgements 4 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

List of contents
Abstract .................................................................................................. 3

Acknowledgements .............................................................................. 4

List of contents ....................................................................................... 5

List of figures ........................................................................................... 6

1. Introduction........................................................................................ 7

2. MATLAB-based programs ................................................................. 12

3. Hardware-based programs .............................................................. 18

4. Conclusions........................................................................................ 35

5. References ......................................................................................... 36

List of contents 5 Group 1


Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

List of figures
Figure 1- Functional Block Diagram............................................................................................. 11
Figure 2- Modulating Signal ........................................................................................................... 14
Figure 3- Carrier wave signal ......................................................................................................... 15
Figure 4- Modulated signal (𝜇 = 0.5) ............................................................................................ 15
Figure 5- Modulated signal (𝜇 = 1.5) ............................................................................................ 16
Figure 6- Periodogram of modulated signal ............................................................................. 17
Figure 7- C5515 eZdsp USB Stick Block Diagram ...................................................................... 18
Figure 8- Project AM Block Diagram ........................................................................................... 19
Figure 9- Main Flowchart ................................................................................................................ 20
Figure 10- AIC3204 Configuration Flowchart ............................................................................ 22
Figure 11- Read data flowchart ................................................................................................... 23
Figure 12- Modulation flowchart .................................................................................................. 24
Figure 13- Write data flowchart .................................................................................................... 25
Figure 14- Create 1KHz sinusoidal signal from Function Generator ................................... 26
Figure 15- Modulating signal (1KHz) ............................................................................................ 27
Figure 16- Carrier wave (10KHz).................................................................................................... 27
Figure 17- Modulated signal with 𝛍 = 0.1 ................................................................................... 28
Figure 18- Modulated signal with 𝛍 = 0.5 ................................................................................... 28
Figure 19- Modulated signal with 𝛍 = 1....................................................................................... 29
Figure 20- Modulated signal with 𝛍 = 1.5 ................................................................................... 29

List of figures 6 Group 1


Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

1. Introduction
1.1. DSP course

First of all, we need to answer the question: What is Digital Signal Processing
(DSP)?
 Digital: operating by the use of discrete signals to represent data in the form of
numbers.
 Signal: a parameter (electrical quantity or effect) that can be varied in such a
way as to convey information.
 Processing: a series operations performed according to programmed
instructions.
So we can define that DSP is changing or analyzing information which is
measured as discrete sequences of numbers. It’s not very hard to find out
applications of DSP around us, which are very familiar to our day life.

In communications:
 Telephone – transmission of information in digital form via telephone lines,
modem technology, mobile phones
 Encoding and decoding of the information sent over a physical channel (to
optimize transmission or to detect or correct errors in transmission)

In music applications:
 Recording
 Playback
 Manipulation (mixing, special effects)

Chapter 1 7 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

In multimedia: Generation storage and transmission of sound, still images, motion


pictures.
 Digital television
 Video conferencing

In image processing:
 Content based image retrieval – browsing, searching and retrieving images
from database
 Image enhancement
 Compression – reducing the redundancy in the image data to optimize
transmission or storage

In speech applications:
 Noise reduction – reducing background noise in the sequence produced by a
sensing device (microphone)
 Speech recognition – differentiating between various speech sounds
 Synthesis of artificial speech – text to speech systems for blind

In biomedical: Analysis of biomedical signals, diagnosis, patient monitoring,


preventive health care, artificial organs
 Electrocardiogram (ECG) signal – provides doctor with information about the
condition of the patient’s heart
 Electroencephalogram (EEG) signal – provides Information about the activity
of the brain

Chapter 1 8 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

In radar and sonar:


 Target detection – position and velocity estimation
 Tracking

DSP is used widely in more and more different domains thanks to its advantages:
 Digital system can be simply reprogrammed for other applications / ported to
different hardware / duplicated
(Reconfiguring analog system means hardware redesign, testing, verification)
 DSP provides better control of accuracy requirements
(Analog system depends on strict components tolerance, response may drift
with temperature)
 Digital signals can be easily stored without deterioration
(Analog signals are not easily transportable and often can’t be processed off-
line)
 More sophisticated signal processing algorithms can be implemented
(Difficult to perform precise mathematical operations in analog form).

The following diagram illustrates how to implement a typical DSP.

The DSP course provides basically knowledge of processing digital signals,


includes problems in sampling and reconstruction, oversampling and noise
shaping, convolution algorithms, Z transformation, DFT/FFT algorithms, linear time-
invariant systems and frequency response of LTI systems. By finishing this course,
students can have an overall view about processing digital signals and can apply
it into real-life where the first simple application is amplitude modulation using
TMS320C5515 eZdsp USB Stick.

“Learning digital signal processing is not something you accomplish; it’s a journey
you take”
R.G Lyons, Understanding Digital Signal processing

Chapter 1 9 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

1.2. TMS320C5515 eZdsp USB Stick

1.2.1. Features

The TMS320C5515 eZdsp USB Stick has following special features suitable for
DSP:
 High-Performance, Low-Power
 TMS320C5515 DSP builds on the TMS320C5514 DSP with an additional 64 KB
on-chip memory (320 KB total)
 Up to 1024-point programmable FFT hardware accelerator
 Integrated LCD display controller and 10-bit, 4-channel SAR ADC – reduce
 system cost and enable more user interactive portable features
 Scalable and pin-to-pin compatible with the TMS320C5514 DSP allowing for
the ability to design an entire product portfolio using the same hardware
and software platform

Chapter 1 10 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

1.2.2. Functional Block Diagram

Figure 1- Functional Block Diagram

1.2.3. Applications
This kit is a multifunction-hardware which can be used for following
applications:
 Portable audio recording
 Wireless microphone
 Noise cancellation headphones
 Medical monitoring
 Biometrics
 Smart sensors

Chapter 1 11 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

2. MATLAB-based programs
2.1. Objectives

To do the simulation of the amplitude modulation (AM) by MATLAB, first, we


create carrier wave signal and modulating signal, then we use Amplitude
Modulation method to modulate signal. After that, we will display the modulated
signal. We also save these results into file *.h. File contains carrier wave signal
(carrier.h) will be used as data to modulate on TMS320C5515 eZdsp USB Stick, we
will mention it later.
Finally, we recheck the results by plot the power spectrum density of
modulated signal.

2.2. Programming code in MATLAB


Below is the modulation code using MATLAB:
% Amplitude Modulation
% AM.m

clear
close all
clc

fprintf(' AM Modulation \n');


Ac=input(' Choose the amplitude of carrier wave: Ac = ');
fc=input(' Choose the frequency of carrier wave: fc = ');
Am=input(' Choose the amplitude of modulating signal: Am = ');
fm=input(' Choose the frequency of modulating signal: fm = ');

m=input(' Choose the modulation index: ');

for i=1:480
signal(i) = Am*sin(2*pi*fm*(i-1)/48000);
carrier(i) = Ac*sin(2*pi*fc*(i-1)/48000);
xc(i)=(1+m*signal(i))*carrier(i);
end

Chapter 2 12 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

% Plot waves
figure
plot(signal,'b')
figure
plot(carrier,'r')
figure
plot(xc,'k')

% Save the result into files .h

% Modulating Signal
fid=fopen('modulatingsignal.h','w');
fprintf(fid,'float Signal[480]={');
fprintf(fid,'%f, ' ,signal(1:479));
fprintf(fid,'%f' ,signal(480));
fprintf(fid,'};\n');
fclose(fid);

% Carrier Wave
fid=fopen('carierwave.h','w');
fprintf(fid,'float carrier[480]={');
fprintf(fid,'%f, ' ,carrier(1:479));
fprintf(fid,'%f' ,carrier(480));
fprintf(fid,'};\n');
fclose(fid);

% Modulated Signal
fid=fopen('modulatedsignal.h','w');
fprintf(fid,'float xc[480]={');
fprintf(fid,'%f, ' ,xc(1:479));
fprintf(fid,'%f' ,xc(480));
fprintf(fid,'};\n');
fclose(fid);

Chapter 2 13 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

2.3. Displayed results


2.3.1. Case 1: μ < 1
We suppose:
 Modulating signal is a sinusoidal signal with frequency fm = 1 KHz and
amplitude Am = 1
 Carrier wave is a sinusoidal signal with frequency fc = 10 KHz and
amplitude Ac = 1
 Modulation index is μ = 0.5 < 1

Simulation results:

Modulating signal x(t):

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 50 100 150 200 250 300

Figure 2- Modulating Signal

Chapter 2 14 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Carrier wave signal c(t):

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 50 100 150 200 250 300

Figure 3- Carrier wave signal

Modulated signal xc(t):

1.5

0.5

-0.5

-1

-1.5
0 50 100 150 200 250 300

Figure 4- Modulated signal (𝜇 = 0.5)

As we can see: Amax = 1.5, Amin = 0.5; and there is no phase reversal.

Chapter 2 15 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

2.3.2. Case 2: μ > 1


We suppose:
 Modulating signal is a sinusoidal signal with frequency fm = 1 KHz and
amplitude Am = 1
 Carrier wave is a sinusoidal signal with frequency fc = 10 KHz and amplitude
Ac = 1
 Modulation index is μ = 1.5 > 1

Simulation results:

Modulated signal xc(t):

2.5

1.5

0.5

-0.5

-1

-1.5

-2

-2.5
0 50 100 150 200 250 300

Figure 5- Modulated signal (𝜇 = 1.5)

As in the figure, we can see there are phase reversals of signal, because
modulation index is larger than 1.

2.3.3. Power Spectrum Density


We begin to analyze the spectrum of the signal xc(t) from the algorithm above
.
We use Periodogram estimation method to display frequency spectrum of
signal xc(t):
2
T N 1
PPER  f    x(nT )e  j 2 fnT

N n 0

Chapter 2 16 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0
0 5000 10000 15000

Figure 6- Periodogram of modulated signal

As in figure, we see spectrum of the signal contains three lines spectrum. The
amplitude of middle line spectrum is bigger than the two others. Frequencies
spectrum respectively is 9KHz, 10KHz and 11KHz (corresponding fc – fm, fc and
fc + fm)

Chapter 2 17 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3. Hardware-based programs
In this chapter, we will discuss about how to implement Amplitude Modulation
by using TMS320C5515 eZdsp USB Stick. The block diagram of the C5515 eZdsp USB
Stick is shown below.

Figure 7- C5515 eZdsp USB Stick Block Diagram

And, these are the function blocks we will use in this project, and we can also see
how they interact with the PC.

Chapter 3 18 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Figure 8- Project AM Block Diagram

In order to implement the Amplitude Modulation, first, we must configure all functions
for the board and configure some parts of the board which we will use.

Second, we create the carrier wave by programming in MATLAB (the same work as
in chapter 2). Then we read the header file ‘carrier.h’ as we had the carrier wave,
with the fixed frequency is 10 KHz and the amplitude can be modify easily.

Chapter 3 19 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Then, we read data from AIC3204 through I2S0 interface, this is the data from LINE IN
of the board. Next, we modulate by multiply the modulating signal and the carrier
wave, then add into it the carrier wave.

Finally, we return the modulated signal by writing data to AIC3204, the signal will be
push out to the LINE OUT of the board. We can overview the whole process in the
flowchart below.

Figure 9- Main Flowchart

3.1 Setup Board function

Int16 USBSTK5515_init( )
{
/* Enable clocks to all peripherals */
SYS_PCGCR1 = 0x0000;
SYS_PCGCR2 = 0x0000;

return 0;
}

Chapter 3 20 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

In the function USBSTK5515_init(), we enable clocks to all peripherals by setting


two registers SYS_PCGCR1 and SYS_PCGCR2 with the value 0x0000 in
hexadecimal.

3.2 Configuration

3.2.1. I2C interface configuration

Int16 USBSTK5515_I2C_init( )
{
I2C_MDR = 0x0400; // Reset I2C
I2C_PSC = 15; // Config prescaler for 100MHz
I2C_CLKL = 25; // Config clk LOW for 100kHz
I2C_CLKH = 25; // Config clk HIGH for 100kHz
I2C_MDR = 0x0420; // Release from reset; Master,
// Transmitter, 7-bit address
return 0;
}

As we can see in the C5515 eZdsp USB Stick Block Diagram, the I2C interface
has to be initial to use AIC3204 chip and OLED 96x16 display. We configure
step by step the values of registers, such as prescaler, clock LOW and HIGH, …

3.2.2. AIC3204 configuration

To configure the AIC3204 chip, we have to follow these steps, as we can see in
the flowchart below.

Chapter 3 21 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Figure 10- AIC3204 Configuration Flowchart

Note that the ADC Routing, is to be used with LINE IN. Meanwhile, the DAC
Routing is to be used in LINE OUT. And I2S is the interaction between AIC3204
chip and the TMS320C5515 digital signal processor.

3.3 Create Carrier wave by Matlab programming

We create a carrier wave with 10KHz from Matlab, and save data into header file
carrier.h, in order to Code Composer Studio can read it.

%Create Carrier wave - sin(10KHz)


%Run with Matlab

for i=1:480
sin10k(i) = sin(2*pi*10000*(i-1)/48000);
end
fid=fopen('carrier.h','w');
fprintf(fid,'float sin10KHz[480]={');
fprintf(fid,'%f, ' ,sin10k(1:479));
fprintf(fid,'%f' ,sin10k(480));
fprintf(fid,'};\n');
fclose(fid);

Chapter 3 22 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3.4 Read data

Figure 11- Read data flowchart

void ReadData(short *ChA_H, short *ChA_L, short *ChB_H, short *ChB_L) {


/* Read Digital audio */
while ((Rcv & I2S0_IR) == 0)
; // Wait for interrupt pending flag
*ChA_H = I2S0_W0_MSW_R; // 16 bit left channel received audio data
*ChA_L = I2S0_W0_LSW_R;
*ChB_H = I2S0_W1_MSW_R; // 16 bit right channel received audio data
*ChB_L = I2S0_W1_LSW_R;
}

To read digital audio, we have wait for interrupt pending flag by checking the rcv
bit in I2S0_IR register, it means that’s the time the TMS320C5515 are ready to read
the audio signal.

While the interrupt flag is active, we have to read data from the register
I2S0_W0_MSW_R (Channel A High) and I2S0_W0_LSW_R (Channel A Low), and the
same with right channel (B channel).

Chapter 3 23 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3.5 Modulation

Figure 12- Modulation flowchart

void AMModulation(unsigned char sample) {


short ChA_H, ChA_L, ChB_H, ChB_L;

ReadData(&ChA_H, &ChA_L, &ChB_H, &ChB_L);


ChA_H = A * sin10KHz[sample] + (A * u / b) * ChA_H * sin10KHz[sample];
WriteData(ChA_H, 0, ChB_H, 0);
}

With sin10KHz[] is the values vector of carrier wave, now we modulate by


multiplying the carrier with the variable ChA_H (the signal from Channel A High),
then adding into it the carrier itself.

The others variables A, u, b are amplitude of carrier, modulation index,


standardized coefficients of signal. Then we write the data to Channel A High and
Channel B High.

Chapter 3 24 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3.6 Write data

Figure 13- Write data flowchart

void WriteData(short ChA_H, short ChA_L, short ChB_H, short ChB_L) {


/* Write Digital audio */
while ((Xmit & I2S0_IR) == 0)
; // Wait for interrupt pending flag
I2S0_W0_MSW_W = ChA_H; // 16 bit left channel transmit audio data
I2S0_W0_LSW_W = ChA_L;
I2S0_W1_MSW_W = ChB_H; // 16 bit right channel transmit audio data
I2S0_W1_LSW_W = ChB_L;
}

Opposite with reading process, to write data to LINE OUT, while the interrupt flag is
active, we write data to the register I2S0_W0_MSW_R (Channel A High) and
I2S0_W0_LSW_R (Channel A Low), and the same with right channel (B channel).

Chapter 3 25 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3.7 Results Display

Modulating Signal (Sin 1KHz)

Figure 14- Create 1KHz sinusoidal signal from Function Generator

Chapter 3 26 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Figure 15- Modulating signal (1KHz)

Carrier Wave (Sin 10KHz)

Figure 16- Carrier wave (10KHz)

Chapter 3 27 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Modulated Signal with modulation index 𝛍 = 0.1

Figure 17- Modulated signal with 𝛍 = 0.1

Modulated Signal with modulation index 𝛍 = 0.5

Figure 18- Modulated signal with 𝛍 = 0.5

Chapter 3 28 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

Modulated Signal with modulation index 𝛍 = 1

Figure 19- Modulated signal with 𝛍 = 1

Modulated Signal with modulation index 𝛍 = 1.5

Figure 20- Modulated signal with 𝛍 = 1.5

Chapter 3 29 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

3.8 Programming Code

main.c

#include "AM.h"
#include "oled_test.c"
/* ------------------------------------------------------------------------ *
* *
* main( ) *
* *
* ------------------------------------------------------------------------ */
void main( void )
{
unsigned char sample;
/* Initialize BSL */
USBSTK5515_init( );
SYS_EXBUSSEL = 0x6100; // Enable I2C bus
USBSTK5515_I2C_init( ); // Initialize I2C
AIC3204Config(); // Configuration AIC3204
oled_test();
while(1)
{
for (sample=0;sample<48;sample++)
AMModulation(sample);
}

Chapter 3 30 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

AM.c
(the main function doing amplitude modulation)
/*
* AM.c
*
* Created on: May 20, 2013
* Author: GROUP 1 - HUY NGUYEN.T – KHOA NGUYEN.T - MY LE.D - TUAN NGUYEN.O
*/
#include "AM.h"
#include "carrier.h"

/* ------------------------------------------------------------------------ *
* *
* _AIC3204_rset( regnum, regval ) *
* *
* Set codec register regnum to value regval *
* *
* ------------------------------------------------------------------------ */
Int16 AIC3204_rset( Uint16 regnum, Uint16 regval )
{
Uint8 cmd[2];
cmd[0] = regnum & 0x007F; // 7-bit Register Address
cmd[1] = regval; // 8-bit Register Data

return USBSTK5515_I2C_write( AIC3204_I2C_ADDR, cmd, 2 );


}

void AIC3204Config(void)
{
/* Configure AIC3204 */
AIC3204_rset( 0, 0 ); // Select page 0
AIC3204_rset( 1, 1 ); // Reset codec
AIC3204_rset( 0, 1 ); // Select page 1
AIC3204_rset( 1, 8 ); // Disable crude AVDD generation from DVDD
AIC3204_rset( 2, 1 ); // Enable Analog Blocks, use LDO power
AIC3204_rset( 0, 0 );
/* PLL and Clocks config and Power Up */
AIC3204_rset( 27, 0x0d ); // BCLK and WCLK are set as o/p; AIC3204(Master)
AIC3204_rset( 28, 0x00 ); // Data ofset = 0
AIC3204_rset( 4, 3 ); // PLL setting: PLLCLK <- MCLK, CODEC_CLKIN <-PLL CLK
AIC3204_rset( 6, 7 ); // PLL setting: J=7
AIC3204_rset( 7, 0x06 ); // PLL setting: HI_BYTE(D=1680)
AIC3204_rset( 8, 0x90 ); // PLL setting: LO_BYTE(D=1680)
AIC3204_rset( 30, 0x88 ); // For 32 bit clocks per frame in Master mode ONLY
// BCLK=DAC_CLK/N =(12288000/8) = 1.536MHz = 32*fs
AIC3204_rset( 5, 0x91 ); // PLL setting: Power up PLL, P=1 and R=1
AIC3204_rset( 13, 0 ); // Hi_Byte(DOSR) for DOSR = 128 decimal or 0x0080 DAC
oversamppling
AIC3204_rset( 14, 0x80 ); // Lo_Byte(DOSR) for DOSR = 128 decimal or 0x0080
AIC3204_rset( 20, 0x80 ); // AOSR for AOSR = 128 decimal or 0x0080 for decimation
filters 1 to 6
AIC3204_rset( 11, 0x82 ); // Power up NDAC and set NDAC value to 2
AIC3204_rset( 12, 0x87 ); // Power up MDAC and set MDAC value to 7
AIC3204_rset( 18, 0x87 ); // Power up NADC and set NADC value to 7

Chapter 3 31 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

AIC3204_rset( 19, 0x82 ); // Power up MADC and set MADC value to 2


/* DAC ROUTING and Power Up */
AIC3204_rset( 0, 1 ); // Select page 1
AIC3204_rset( 0x0c, 8 ); // LDAC AFIR routed to HPL
AIC3204_rset( 0x0d, 8 ); // RDAC AFIR routed to HPR
AIC3204_rset( 0, 0 ); // Select page 0
AIC3204_rset( 64, 2 ); // Left vol=right vol
AIC3204_rset( 65, 0); // Left DAC gain to 0dB VOL; Right tracks Left
AIC3204_rset( 63, 0xd4 ); // Power up left,right data paths and set channel
AIC3204_rset( 0, 1 ); // Select page 1
AIC3204_rset( 0x10, 0x00 );// Unmute HPL , 0dB gain
AIC3204_rset( 0x11, 0x00 );// Unmute HPR , 0dB gain
AIC3204_rset( 9, 0x30 ); // Power up HPL,HPR
AIC3204_rset( 0, 0 ); // Select page 0
USBSTK5515_wait( 100 ); // wait
/* ADC ROUTING and Power Up */
AIC3204_rset( 0, 1 ); // Select page 1
AIC3204_rset( 0x34, 0x30 );// STEREO 1 Jack
// IN2_L to LADC_P through 40 kohm
AIC3204_rset( 0x37, 0x30 );// IN2_R to RADC_P through 40 kohmm
AIC3204_rset( 0x36, 3 ); // CM_1 (common mode) to LADC_M through 40 kohm
AIC3204_rset( 0x39, 0xc0 );// CM_1 (common mode) to RADC_M through 40 kohm
AIC3204_rset( 0x3b, 0 ); // MIC_PGA_L unmute
AIC3204_rset( 0x3c, 0 ); // MIC_PGA_R unmute
AIC3204_rset( 0, 0 ); // Select page 0
AIC3204_rset( 0x51, 0xc0 );// Powerup Left and Right ADC
AIC3204_rset( 0x52, 0 ); // Unmute Left and Right ADC

AIC3204_rset( 0, 0 );
USBSTK5515_wait( 200 ); // Wait

/* I2S settings */
I2S0_SRGR = 0;
I2S0_CR = 0x8010; // 16-bit word, slave, enable I2C
I2S0_ICMR = 0x3f; // Enable interrupts
}

/* ------------------------------------------------------------------------ *
* *
* ReadData(Channel A high, Channel A low, Channel B high, Channel B low) *
* *
* Read signal from STEREO IN port *
* *
* ------------------------------------------------------------------------ */
void ReadData(short *ChA_H, short *ChA_L, short *ChB_H, short *ChB_L) {
/* Read Digital audio */
while ((Rcv & I2S0_IR) == 0)
; // Wait for interrupt pending flag
*ChA_H = I2S0_W0_MSW_R; // 16 bit left channel received audio data
*ChA_L = I2S0_W0_LSW_R;
*ChB_H = I2S0_W1_MSW_R; // 16 bit right channel received audio data
*ChB_L = I2S0_W1_LSW_R;
}

/* ------------------------------------------------------------------------ *

Chapter 3 32 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

* *
* WriteData(Channel A high, Channel A low, Channel B high, Channel B low) *
* *
* Write signal to STEREO OUT port *
* *
* ------------------------------------------------------------------------ */
void WriteData(short ChA_H, short ChA_L, short ChB_H, short ChB_L) {
/* Write Digital audio */
while ((Xmit & I2S0_IR) == 0)
; // Wait for interrupt pending flag
I2S0_W0_MSW_W = ChA_H; // 16 bit left channel transmit audio data
I2S0_W0_LSW_W = ChA_L;
I2S0_W1_MSW_W = ChB_H; // 16 bit right channel transmit audio data
I2S0_W1_LSW_W = ChB_L;
}

/* ------------------------------------------------------------------------ *
* *
* AMModulation(sample) *
* *
* Modulate signal with AM method *
* *
* ------------------------------------------------------------------------ */
void AMModulation(unsigned char sample) {
short ChA_H, ChA_L, ChB_H, ChB_L;

ReadData(&ChA_H, &ChA_L, &ChB_H, &ChB_L);


ChA_H = A * sin10KHz[sample] + (A * u / b) * ChA_H * sin10KHz[sample];
WriteData(ChA_H, 0, ChB_H, 0);
}

usbstk5515.c

#include "usbstk5515.h"

/* ------------------------------------------------------------------------ *
* *
* USBSTK5515_wait( delay )
*
* *
* Wait in a software loop for 'x' delay *
* *
* ------------------------------------------------------------------------ */
void USBSTK5515_wait( Uint32 delay )
{
volatile Uint32 i;
for ( i = 0 ; i < delay ; i++ ){ };
}

/* ------------------------------------------------------------------------ *
* *
* _waitusec( usec ) *

Chapter 3 33 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

* *
* Wait in a software loop for 'x' microseconds *
* *
* ------------------------------------------------------------------------ */
void USBSTK5515_waitusec( Uint32 usec )
{
USBSTK5515_wait( (Uint32)usec * 8 );
}

/* ------------------------------------------------------------------------ *
* *
* USBSTK5515_init( ) *
* *
* Setup board board functions *
* *
* ------------------------------------------------------------------------ */
Int16 USBSTK5515_init( )
{
/* Enable clocks to all peripherals */
SYS_PCGCR1 = 0x0000;
SYS_PCGCR2 = 0x0000;

return 0;
}

Chapter 3 34 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

4. Conclusions
The modulated signals from MATLAB-based programs and hardware-based
programs are generally identical. They have the same wave shape and spectrum.
The frequencies of received signals based on two methods are basically met the
requirement of the project. However, it still remains some very small differences
belong to the results from the TMS320C5515 eZdsp USB Stick compared to the ideal
simulate on MATLAB because of following objective reasons:
 Connectors between cables and computer, and between cables and kit are
not ideal.
 Perturbations from inside the cables and from surrounding environment
 Digital signal processing in the kit is not perfectly precise
 etc.
The above comparisons show that the amplitude modulation using TMS320C5515
eZdsp USB Stick is carried out totally accurately, with acceptable errors in case of
requirements of this project.

Chapter 4 35 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

References
[1]. Assoc. Prof. Dr. Thuong Le-Tien, Chapter 3 lecture in the Analog & Digital
Modulations course.

[2]. A. Bruce Carlson, Communication Systems, 5th Edition, McGraw Hill.

[3]. Sample Test “aic3024_test.c” and “oled_test.c” in the directory folder of Code
Composer Studio 4.1.3

(...\Texas Instruments\ccsv4\emulation\boards\usbstk5515_v1\tests)

[4]. Quick start guide for usbstk5515

[5]. TMS320C5515 eZdsp™ USB Stick Technical Reference

[6]. TMS320C5515 eZdsp™ USB Stick Development Tool

[7]. TMS3320C5515 DSP System - User's Guide

[8]. TMS320C5515 Fixed-Point Digital Signal Processor

[9]. TLV320AIC3204 Ultra Low Power Stereo Audio Codec

[10]. Design and Configuration Guide for the TLV320AIC3204 and TLV320AIC3254
Audio Codecs

References 36 Group 1
Amplitude Modulation Using TMS320C5515 eZdsp USB Stick Assoc. Prof. Dr. Thuong Le-Tien

37 Group 1

Vous aimerez peut-être aussi