APPLICATIONS OF DIGITAL SIGNAL PROCESSING METHODS FOR 4G COMMUNICATION SYSTEMS

Anna Torrens

Senior Project Report

Course: EECE 419

Date submitted: January 10, 2012

Advisor: Dr. Evriclea Voudouri-Maniati

Manhattan College ABSTRACT

The increasing interest of users in multimedia applications of is growing up very fast; this is the reason why mobile wireless networks are converging to a new generation where the speed is one of the issues. This project, which has been developed in Manhattan College, a University in New York City, evaluates the technique of OFDM.

OFDM is used in the current generation of mobile communication as well as in the upcoming generations like 4G and beyond. Specifically, an introduction to the LTE (one of the fourth generation standards) is provided followed by a review of the features of OFDM. A simulation with MATLAB code demonstrates that the transmitted video data can be recovered at the receiver without errors in the presence of indoors and outdoors multipath fading. In addition, as Manhattan College has acquired the Texas Instruments 6713 DSP Starter Kit (DSK), the form of the previous theoretical research has been applied to a practical experiment, in the implementation of the OFDM transmitter.

2 Manhattan College OVERVIEW

Nowadays mobile communications are getting a central role in our society. Few years ago a cell phone was used only for voice, but with the introduction of data new directions have been researched to solve the demand of the users. In this report we want to introduce the fourth generation as the new technology of mobile wireless network, and be involved in one of its standards for transmission and reception of data called OFDM.

The main goal of this project is to demonstrate the immunity of OFDM to multipath effect by implementing its transmitter and receiver, modeling a probable real channel, and evaluating the system’s performance by recovering the transmitted code without any errors. As we are living a transition from to newer generations, we are going to take advantage of the mobile system of the future, LTE, which uses this kind of modulation. This report can provide future students an overview of new technologies for mobile wireless systems and more efficient techniques of transmission and reception, like OFDM. From this point on, new experiments may be developed originating from the implemented MATLAB simulations and programming of the Texas Instruments TMS320C6713 DSK. They can also witness the fact that it is easier to obtain results via a simulation compared to trying to do the same thing with hardware. As my period in Manhattan College is limited, only the OFDM transmitter was implemented with the DSP Starter Kit. The project is open to new implementations and investigations.

In the first part of the research, there is a review of all generations of mobile wireless that have been existed up to now. We focus in the new one by providing a short description of the standards that have been approved by the ITU-R. As this project has been implemented in the United States, it is based on LTE, which actually big companies like AT&T and Verizon wireless are gradually introducing in some states.

Then, there is a description of OFDM presenting its characteristics and its advantages and disadvantages. One of the features of this technique is that can mitigate

3 Manhattan College multipath effect. We explain how the channel produces it, and how good OFDM is in eliminating it. There is also a brief explanation and block diagram of the OFDM transmitter and the OFDM receiver. We comment OFDMA as the way of transmission that the fourth generation uses; it is based on OFDM, the previous technique, but sharing more flexibility to the spectrum of the total bandwidth with other users is accomplished.

The next section demonstrates how the theory OFDM system behaves under fading conditions. To accomplish this, we simulate a transmitter and a receiver with the parameters of the LTE standard and we add a channel with multiple paths. Matlab code has been developed for this purpose.

Finally, we try to implement the OFDM transmitter with hardware and simulate a real case. The 6713 DSP Starter Kit (DSK) is programmed to generate the video data, apply the IFFT and perform the digital to analog conversion of the signal and radio frequency modulation. As the time was limited, there is only the transmitter implementation.

4 Manhattan College

TABLE OF CONTENTS

1. INTRODUCTION ...... 6 2. REVIEW OF MOBILE NETWORK ...... 8 3. 4G STANDARDS: LTE AND WIMAX ...... 12 4. 4G IN US ...... 15 5. OFDM ...... 17 5.1 DEFINITION ...... 17 5.2 GENERATION OF SUBCARRIERS USING THE IFFT ...... 18 5.3 IMPORTANCE OF ORTHOGONALITY ...... 19 5.4 ADVANTAGES AND DISADVANTAGES OF OFDM ...... 20 5.5 PHENOMENA OF THE MOBILE RADIO ENVIRONMENT-PROPAGATION ...... 21 5.6 HOW OFDM MITIGATES MULTIPATH EFFECT ...... 24 5.7 TRANSMITTER AND RECEIVER OPERATION ...... 25 6. OFDMA ...... 30 7. MATLAB SIMULATION ...... 32 7.1 CHANNEL MODEL ...... 32 7.2 SIMULATION RESULTS ...... 38 7.1.1 OFDM transmitter ...... 38 7.1.2 OFDM receiver ...... 44 7.1.3 OFDM receiver with multipath channel ...... 47 8. THE 6713 DSP STARTER KIT (DSK) ...... 55 8.1 DSK DESCRIPTION ...... 55 8.2 RESULTS ...... 59 9. CONCLUSION ...... 70 10. FUTURE LINES ...... 71 11. REFERENCES ...... 72 12. BIBLIOGRAPHY ...... 75

5 Manhattan College 1. Introduction

Since ancient times, mankind has always tried to find ways to communicate, namely to have a process of transmission and reception of information. The purpose of network is carry information signals via a media between two or more points that are geographically separate. The basic elements of telecommunication are shown in figure 1. The users that are involved are called source and destination. The information that is transmitted (it can be a photo, voice, data, etc.) has to be transformed into an electrical signal to be sent. That is the reason that there is a transducer after the calling subscriber and before the called subscriber.

Information source Information sink Speaker

Mic CHANNEL Ear TRANSDUCER TRANSMITTER RECEIVER TRANSDUCER

Camera Eye Display Figure 1. Basic elements of telecommunication – Adaptation of [1].

To transmit a message a signal is used which contains the information to be conveyed. Before the invention of the Morse code, the world use to utilize traffic lights, seismic signals, etc. in order to communicate. Later on, with the discovery of the electricity, signals began to be an object of study and today still are a researching goal in the communications area.

This project is focused in the two things we have already mentioned: from now on we are going to be engrossed in wireless communication, specifically, mobile communication, and we are going to concentrate on the way the signal is transmitted on the air knowing that there is the phenomenon of fading.

6 Manhattan College

Over the last decade, the interest in mobile communications has been growing up. This is the reason that mobile systems have been evolved through several generations. Nowadays the cell phones are not used only to communicate with another person; today it is a way to know-everything-anywhere.

7 Manhattan College 2. Review of mobile network

At the present time people talk about our third generation mobiles and also that there is going to be a transition to a fourth generation. But, what does the first and the second generation mean? What are they talking about?

Figure 2. Evolution of mobile phones. [2]

First Generation wireless technology The first generation (1G) of mobile wireless communication represents a set of standards developed in the 80’s based in analog technology. It is the reason that commonly people talk about 1G or analog systems. Some features about analog systems are: • Designed for voice, not for data. • As the name says, it uses analog modulation to transmit voice information. • Are based on circuit-switched technology. • The voice is not encrypted because the analog data does not permit effective encryption systems. • Analog systems do not use error correction codes. It means that the quality of the signal is poor but acceptable. • Analog systems use FDMA (Frequency Division Multiple Access). • There is not a good spectral efficiency: a channel is reserved for a user although he is not going to use it all the time.

8 Manhattan College

1G introduced the cellphone mobiles which were relatively heavy and expensive. They used cell networks with multiple base stations. One of the features of cell systems is their ability to handover a call from one tower to another while communication is in progress.

Listed below are the most famous standards created for the first generation: • AMPS (Advanced System): Based in FM radio using FDMA (Frequency Division Multiplexing Access) where one channel is assigned for the communication between two users. It was used in America, Africa, East Europe and Russia. • ETACS (Extended Total Access Communications System): Basically used in Europe. • NMT (Nordic Mobile Telephone): Used in Scandinavian countries.

Second Generation wireless technology The second generation (2G) emerged in the 90’s due to the shift towards digital communications. Although analog systems can provide similar features, digital systems are more flexible. Digital technology improves systems performance but increases systems complexity by several ways: the voice is digitalized (it produces better quality of voice); there is a spectral efficient radio modulation; it provides secure communications through encrypted systems; it uses correction codes. In particular, the voice data rate is highly than first generation rate but there is a limitation with the transmission of the data information. 2G introduces improvements in cellphones: they are not too big as 1G mobile phones and the battery power consumption decreases; that is because the transmission is not taking place constantly, it occurs in short periods of time (bursts) and because the transmitter has the ability to disconnect when there are silence periods between the users. Typical digital cellular systems use two kind of channels: channels to transmit voice information and control channels. One radio channel is combined with one control channel and one or more voice channels.

9 Manhattan College

The most common standard is GSM (Global Systems for Mobile Communication). It is a combination between two technologies, TDMA and FDMA. CDMA systems emerged in the United States as the IS-95 CDMA.

Third Generation wireless technology Demand for voice services has traditionally been a market driver. However, today, demand for data services has emerged as an equally significant market driver. The concept of 3G wireless technology represents a shift from voice-centric services to multimedia- oriented (voice, data, video, fax) services [3]. The third generation of mobile communications enhanced the implementation of sophisticated wireless applications such as mobile video, music downloads, e-mail, messaging, location-based services, mobile gaming and surfing which are just a sample of the many data services users will have access to. For example, using a second generation version a three minute song takes between six and nine minutes to download. Using 3G it can download in 11 to 90 seconds [4]. 2G mobile communication systems have some limitations and disadvantages such as lower system capacity, lower data rate and mostly voice centric. Third generation systems support higher data transmission rates and higher capacity, which makes them suitable for high-speed data applications as well as for the traditional voice calls [1].

Some of the main goals for this generation were: • Increase the efficiency and capacity than previous generations. • New services such as connecting PC’s through wireless networks and multimedia applications. • Dynamic bandwidth adaptable to the needs of each application. • More flexibility in terms of using multiple standards, frequency bands and support to previous standards. • Faster access: 384Kbps for wireless communications and 2Mbps to fixed access.

There are several systems and standards of 3G, which became available in different geographic areas. Each one with their own features mainly the frequency range of the spectrum and the multiplexing technologies [5].

10 Manhattan College

Fourth Generation wireless technology The spectacular growth of video, voice and data communication over the Internet, and the rapid pervasion of mobile justify great expectations for mobile multimedia [6]. The 4G systems would need to support high-data-rate data transmission over wide areas with reduced delay to meet a variety of requirements derived from the two-way enhanced reality communications such as 3D-audio, 3D-video, and information media world. Although 3G do provide wide-area coverage, they support relatively low data rates. 4G will offer all types of services at an affordable cost, and will support all forthcoming applications (wireless access, a multimedia messaging service, video chat, mobile TV, high definition TV content, and other streaming services for “anytime- anywhere”). The cost of the data transfer would be comparatively much less and global mobility would be possible. 4G will be a fully IP-based (International Protocol) integrated system. This will be capable of providing 100Mbps and 1Gbps speeds both indoors and outdoors, with premium quality and high security. The antennas will be much smarter and improved access technologies such as OFDM and CDMA will be used [1].

1990's 2000's 2010's GENERATION 2G 3G 4G Digital Cellular High speed access Ultra high speed access Internet ATM Network Ubiquitous access

Mobile Mobile Internet Mobile Ubiquitous Multimedia MEDIA SERVICES i-mode, SMS FOMA E-mail Broadband & Web Video mail Ubiquitous browsing Visual phone TV conference Personalized communications Reality communications Figure 3. Evolution of the Mobile Communication Systems. [7]

11 Manhattan College 3. 4G standards: LTE and WIMAX

One of the explanations why fourth generation of mobile communication systems are being investigated and standardized is the fast growth of mobile traffic volume. For that reason, in 2008, the International Telecommunication Union Radiocommunication Standardization Sector (ITU-R) invited submission of candidate technologies for International Mobile Advanced (IMT-A) standard [8]. The main two candidates for 4G systems are WiMAX technology, based on IEEE802.16 standards, and the Third Generation Partnership Project’s (3GPP’s) Long Term Evolution (LTE), both of which are being further enhanced. They are similar in some aspects and features to satisfy the requirements and expectations set by ITU-R although they have somewhat different designs. For example, both technologies deploy OFMA (Orthogonal Frequency Division Multiple Access) combined with various modes of MIMO (Multiple Input Multiple Output) and fast link adaptation with time-frequency scheduling at the physical layer. In the medium access control (MAC) both can support a mix of macrocells, , and relay nodes, which brings all kind of solutions for mobility, interference, and traffic management [9].

EVOLUTION OF DIGITAL CELLULAR STANDARDS

1G 2G 2.5G 3G 4G

GSM WIMAX (TDMA) GPRS EDGE

DataTac PDC WCDMA HSPA (TDMA) (UMTS) (UMTS)

iDEN AMPS HSPA+ (TDMA) LTE (UMTS)

IS-136 EV-DO (TDMA) (CDMA2000) NMT LTE-A

IS-95A IS-95B 1x (CDMA) (CDMA) (CDMA2000)

Figure 4. Evolution of digital cellular standards - Adaptation of [10].

12 Manhattan College

LTE‐Advanced

LTE Release 8 is one of the primary broadband technologies based on OFDM, which is currently being commercialized. LTE Release 8 was finalized in 2008, and can provide downlink and uplink peak rates up to 300 and 75Mbps, respectively, low latency, reduced operating costs, multi-antenna support, macro/microcell layout, improved system capacity and coverage and a significant increase in spectrum efficiency. At the end of 2010, 3GPP has concluded the work on LTE-Advanced (also known as LTE Release 10), and it enhances the existing LTE Release 8 [11].

The list below is the system performance requirements. • LTE-Advanced shall be backwards compatible with LTE Release 8. • Peak data rate  1Gbps data rate will be achieved by 4-by-4 MIMO and transmission bandwidth wider than approximately 70 MHz. • Peak spectrum efficiency  DL: LTE Release 8 satisfies IMT-Advanced requirement.  UL: Need to double from Release 8 to satisfy IMT-Advanced requirement.

LTE- IMT- Rel. 8 LTE Advanced Advanced DL 300 Mbps 1Gbps Peak data rate 1Gbps(*) UL 75 Mbps 500 Mbps Peak spectrum DL 15 30 15 efficiency [bps/Hz] UL 3.75 15 6.75 (*) “100 Mbps for high mobility and 1 Gbps for low mobility” is one of the key features.

• Capacity and cell-edge user throughput • Spectrum flexibility  Actual available spectra are different according to each region or country  In 3GPP, various deployment scenarios for spectrum allocation are being taken into consideration in feasibility study.

13 Manhattan College

 Support for flexible deployment scenarios including downlink/uplink asymmetric bandwidth allocation for FDD and non-contiguous spectrum allocation.

Total 12 scenarios are identified with highest priority

Tx BWs No. of Component Carriers (CCs) Bands Duplex UL: 40 MHz UL: Contiguous 2x20 MHz CCs 1 3.5 GHz band FDD DL: 80 MHz DL: Contiguous 4x20 MHz CCs 2 100 MHz Contiguous 5x20 MHz CCs Band 40 (2.3GHz) TDD 3 100 MHz Contiguous 5x20 MHz CCs 3.5 GHz band TDD UL: Non-Contiguous 20 + 20 MHz CCs UL: 40 MHz 4 DL: Non-Contiguous 2x20 + 2x20 MHz 3.5 GHz band FDD DL: 80 MHz CCs UL: 10 MHz UL/ DL: Non-Contiguous 5 + 5 MHz CCs 5 Band 8 (900MHz) FDD DL: 10 MHz Non-Contiguous 2x20 + 2x20 MHz CCs 6 80 MHz Band 38 (2.6GHz) TDD

… … … … …

These requirements are met using a variety of techniques, including: • Carrier aggregation • DL special multiplexing using up to eight-layer multiple-input multiple-output (MIMO) • DL intracell CoMP transmission and reception • UL Spatial Multiplexing using four-layer MIMO

14 Manhattan College 4. 4G in US

Although the fourth generation of mobile wireless is still developing, some companies in the United States are announcing the arrival of this new generation in its stores and web sites, and are beginning to deploy it in some of the States. The intention is to continue expanding 4G network coverage in the coming years to bring faster speeds to more people.

The main reason that these companies are giving 4G to all cell phone users is to aggressively promote the move into this new generation and take advantage of the increase of the speed in comparison to 3G. With faster speed, data transfers take less time to complete, so there are some advantages that the user can experience. For example:  Stream movies with less buffering  Download and view HD movies faster  Download songs in a few beats and Upload photos is a flash  Watch live TV in HD  Play multiplayer online games  Load web sites quickly [12]  Download business presentations much faster

Despite the fact that one of the features that the ITU-R requires from 4G is to get speeds as high as 100Mbps, the data rate that the American companies can support is not higher than 12Mbps by the present time. Verizon Wireless gives in his web site an interesting comparison between the speed of 3G and 4G:

Figure 5. Verizon speed comparison between 3G and 4G. [13]

15 Manhattan College

As mentioned before, this project focuses in LTE standard because it has been chosen by big companies as AT&T and Verizon Wireless to deploy 4G in the United States. From now on, all simulations and specific parameters will refer to LTE-A.

The table below shows the overall rating, as it is presented in reference [14], of the top ten companies in the United States and the standard they are using or they foresees to use in the new generation of mobile wireless.

Verizon Boost Virgin U.S. Wireless AT&T Sprint T-Mobile Mobile Cricket Mobile Cellular MetroPCD TracFone

4G standard LTE LTE LTE HSPA+ ------

Overall Rating

Table 1. Overall rating of the top ten companies.

16 Manhattan College 5. OFDM

Third and fourth generations of mobile wireless have chosen OFDM as a technique to transmit and receive. In the next sections there are the description and the features of OFDM.

5.1 Definition

OFDM (Orthogonal Frequency Division Multiplex) is a combination of modulation and multiplexing. This communication technique divides a frequency channel in a determinate number of frequency bands that are orthogonal to each other and transmitted in parallel. It increases the spectrum efficiency because the sub-carriers can be overlapped without any interference (the separation of the sub-carriers is theoretically minimal), so a bandwidth saving is achieved. [15] Every frequency band transmits a sub-carrier that is modulated by the data (a portion of user information). OFDM can also be considered a multiple access technique as individual carriers are modulated by groups of sub-carriers and can be assigned to different users. This case will be discussed later.

Ch.1 Ch.2 Ch.3 Ch.4 Ch.5 Ch.6

Frequency (a)

Saving of bandwidth

Frequency (b) Figure 6. a) Conventional multicarrier technique, b) modulation with orthogonal carriers - Adaptation of [16].

17 Manhattan College

5.2 Generation of subcarriers using the IFFT

An OFDM signal consists of a sum of subcarriers that are modulated by using phase shift keying (PSK) or quadrature amplitude modulation (QAM). One OFDM symbol starting at t=ts can be written as

! !!! ! � + 0.5 � � = �� � exp (�2�(� − )(� − � )) , � ≤ � ≤ � + � !!!!/! ! � ! ! ! !! !! !

� � = 0, � < �! �� � > �! + �

Where �! are the complex QAM symbols, �! is the number of subcarriers, � the symbol duration, and �! the carrier frequency.

In this representation, the real and the imaginary parts correspond to the in-phase and quadrature parts of the OFDM signal, which have to be multiplied by a cosine and sine of the desired carrier frequency to produce the final OFDM signal.

The complex baseband OFDM signal as defined previously is in fact nothing more than the inverse Fourier transform of Ns QAM input symbols. The time discrete equivalent is the inverse discrete Fourier transform (IDFT) where the time t is replaced by a sample number n.

!!!! �� � � = � exp (�2� ) ! � !!!

In practice, this transform can be implemented very efficiently by the inverse fast Fourier transform (IFFT). The IFFT drastically reduces the amount of calculations by exploiting the regularity of the operations in the IDFT [6].

18 Manhattan College

5.3 Importance of orthogonality

We know that area under one period of a sine or cosine wave is zero, as shown in the next expression. Mathematically two signals are called orthogonal if the following condition in met:

! ∗ �! � · �! � · �� = 0 !

If we multiply two sine waves with frequencies m and n, where both m and n are integers, then the integral over one period will be:

!! sin ��� · sin ��� · �� = ! 1 !! 1 !! = cos � − � �� · �� − cos � + � �� · �� = 0 − 0 = 0 2 ! 2 !

The integer is discomposed by two components that are sinusoids, so the area under one period will also be zero. As seen before, when a sinusoid of frequency n is multiplied by a sinusoid of frequency m (where m and n are integers), the area under the product is zero. OFDM is similar to FDM but much more spectrally efficient because the frequencies are orthogonal (they are perpendicular in a mathematical sense), so the sub-channels are spaced much closer together. To conclude let us consider an easy example: Assume that we have 5f bandwidth for transmission. If we use the FDM technique and we consider that every carrier has a space of f, then we will be transmitting 5 carriers as shown in the next figure.

f1 f2 f3 f4 f5

f f f f f Figure 7. Carrier assignment using FDM technique - Adaptation of [1].

19 Manhattan College

However, if the frequencies are integer multiples of each other, for example f2=2f1, f3=3f1, f4=4f1, f5=5f1, then these can be closely spaced because they are not going to interfere each other. It means that there is a better usage of spectrum.

5.4 Advantages and disadvantages of OFDM

What are the benefits that make OFDM becomes the more used technique? It has been talked about the high spectrum efficiency that OFDM can offer, but there are more features or reasons that has to be mentioned. Below there is a list with some of its advantages and disadvantages of OFDM compared to single carrier systems.

 Advantages of OFDM

• Makes efficient use of the spectrum by allowing overlap.

• By dividing the channel into narrowband flat fading sub-channels, OFDM is more resistant to frequency selective fading than single carrier systems are.

• Eliminates ISI and ICI through use of a cyclic prefix.

• Using adequate channel coding and interleaving one can recover symbols lost due to the frequency selectivity of the channel.

• Channel equalization becomes simpler compared to using adaptive equalization techniques with single carrier systems.

• It is possible to use maximum likelihood decoding with reasonable complexity.

• OFDM is computationally efficient by using FFT techniques to implement the modulation and demodulation functions.

• It is less sensitive to sample timing offsets than the single carrier systems are.

20 Manhattan College

• Provides good protection against co-channel interference and impulsive parasitic noise.

 Disadvantages of OFDM

• It is more sensitive to carrier frequency offset and drift than single carrier systems [17].

• The OFDM time-domain signal has a relatively large peak-to-average ratio. . Tends to reduce the power efficiency of the RF amplifier. . Non-linear amplification destroys the orthogonality of the OFDM signal and introduced out-of-band radiation.

5.5 Phenomena of the mobile radio environment‐propagation

Mainly, in a wireless communication, if the OFDM signal is transmitted over a multipath channel the consequence is the extension of the signal. It can produce inter- carrier interference or ICI (no orthogonality between the sub-carriers) and inter-symbol interference or ISI (digital symbols overlap into their adjacent). However, one of the basic reasons to use OFDM is the efficient way it can handle multipath propagation.

Multipath effect The transmitted signal is reflected by many obstacles that are in the propagation channel (buildings, cars, houses, trees…). It means that a part of the signal energy is received before others, which are delayed in time [18]; therefore, the received signal arrives from many directions over multiple paths.

There are two types of paths we should study, and they are defined in the book Mobile Handset Design from Sajal Kumar Das as: • LOS (Line-of-Sight): the straight-line path of the wave from the transmitter (TX) directly to the receiver (RX). • NLOS (Non-Line-of-Sight): the path of a wave arriving at the receiver after reflection from various reflectors.

21 Manhattan College

Multipath effect will cause fading; it means that there can be fluctuations in the amplitude and the phase of the received signal. If multipath signals are in phase with the direct path signal the received signal will be greater (constructive reflections), but if contrary they are out of phase the intensity of the received signal will be lower (destructive reflections). Consequently, there will be a degradation of the signal. [1]

REFLECTOR (building)

REFLECTOR (house, tree)

Reflected path

Direct path

A·sin(!t) + B·sin(!t+p) + ·sin(!t+q) + ... MOBILE Figure 8. The multipath effect in a wireless channel - Adaptation of [1].

Inter‐symbol Interference (ISI) Inter-symbol Interference refers to the incident that happens when symbols overlap with their adjacent or following symbols. As a result, the receiver cannot make a correct interpretation of the pulse received.

The figures below are an example of an ISI that can be useful to understand the concept. Let us suppose the next sequence to be sent by the wireless channel:

Figure 9. Sequence 101101 to be sent. [19]

22 Manhattan College

Figure 10 represents how the symbols are going to arrive at the receiver. As we can see one symbol interferes with one or more following symbols.

Figure 10. Symbols at the receiver. [19]

Next figure shows the summed received symbols.

Figure 11. Sequence 101101 at the receiver. [19]

If we look at time=3 the receiver is detecting approximately a half of the transmitted value. It is important to notice because the receiver may recognize it as noise even though it is the pulse that has been received. Obviously, there could be a wrong interpretation of the pulse as a consequence of this phenomenon. [19]

Inter‐carrier Interference (ICI) A major problem in OFDM is its vulnerability to frequency offset errors between the transmitted and received signals, which may be caused by the difference between the transmitter and receiver local oscillator frequencies. In such situations, there is a loss of the orthogonality of the sub-carriers, which results in Inter-carrier Interference (ICI). ICI

23 Manhattan College results from the other sub-channels in the same data block of the same user. ICI problem would become more complicated when the multipath fading is present. If ICI is not properly compensated it results in power leakage among the subcarriers, thus degrading the system performance. [20]

5.6 How OFDM mitigates multipath effect

A conventional solution to multipath is adding an equalizer in the receiver, but it is too complicated. OFDM mitigates multipath fading in two ways:

 Guard band A cyclic prefix is added to the OFDM symbol to reduce the effect of the delay produced by multipath effect and to keep the orthogonality between the sub- carriers, so that multipath components from one symbol cannot interfere with the next symbol. To achieve this, the OFDM symbol is slightly increased in time duration. Instead of keeping the guard times blank, the initial first few values from the vector are copied into the guard band. The disadvantage of using a cyclic extension is a less available bandwidth for the real data transmission [21].

Signal Symbol N Symbol N+1 Symbol N+2

Echo Symbol N Symbol N+1 Symbol N+2

(a) Interference

Guard Band (GB)

Signal Symbol N GB Symbol N+1 GB Symbol N+2 GB

Echo Symbol N GB Symbol N+1 GB Symbol N+2 GB

(b) Interference in the guard band

Figure 12. (a) Symbol interference, (b) band guard in the OFDM symbol.

24 Manhattan College

 Narrowband subcarriers OFDM involves converting the input into multiple low-rate streams that are transmitted on separate narrowband subcarriers that are allowed to overlap orthogonally in frequency. This also converts a frequency-selective fading channel over the OFDM bandwidth into subcarriers that each experience flat fading, allowing for simple one-tap equalization per subcarrier [22].

5.7 Transmitter and receiver operation

It is important to describe the procedure which is followed to transmit a signal. It is interesting and necessary to understand the changes that are taking place in the signal so that it can be transmitted and received. We are going to study this valuable process in a general way, and in spite the signal impairments by the channel we will reconstruct the signal that was sent.

Review of transforms To have a good comprehension of the process of transmission and reception that is used in OFDM it is necessary to understand the mathematical tools that are used for signal processing.

25 Manhattan College

Name of the transform Definition What it is used for

X ω !"#$%& !"#$%& = = TF x t = ! = x(t)e!!!! dt The FT let us have a !! relationship between the

FT (Fourier Transform) frequency and the time X e!!! = !"#"$%& !"#$%& domain in analog and = TF x n = digital signals. ! = x[n]e!!!! !!!!

X k = DFT! x n = !!! The DFT let us have a !" !! !" = x n e ! , discrete frequency DFT (Discrete Fourier Transform) !!! representation of digital ∀ k ∈ 0, N − 1 , signals. L ≡ finite duration of the signal

The FFT is an algorithm FFT (Fast Fourier Transform) - which computes efficiently the DFT.

26 Manhattan College

OFDM transmitter A very basic implementation of an OFDM transmitter is presented below.

Figure 13. General OFDM transmitter. [23]

The input serial data stream of binary digits s[n] is changed into a parallel format by inverse multiplexing. The process is shown in the next example.

If we examine the bit sequence 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, - 1, 1 and suppose that it has to be transmitted using 4 sub-carriers; we have done a serial to parallel conversion. Note that each column represents the bits that will be carried by one sub-carrier.

Carrier 1 Carrier 2 Carrier 3 Carrier 4 1 1 -1 -1 1 1 1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1 1

Table 2. Serial to parallel conversion of input data bits. [24]

The next step is to employ a quadrature amplitude modulation (QAM) or quadrature phase-shift keying (QPSK) for mapping the data bits in each sub-carrier.

27 Manhattan College

Figure 14. Generation of symbols. [24]

Time

Frequency

Figure 15. Modulated sub-carriers to be transmitted. [24]

The resulting N complex samples or symbols coming from the N sub-carriers are extended to be a 2N complex symmetric sequence.

Figure 16. Frequency domain distribution of symbols. [25]

An Inverse Fast Fourier Transform (IFFT) is used to transform the data back to the time domain samples. To ensure the orthogonality between the sub-carriers, a guard period is added to the start of each symbol. After that, the symbols are converted back to a serial time waveform by a parallel to serial converter to form the signal for the OFDM transmission.

28 Manhattan College

Finally the signals are converted to an analog form using a digital-to-analog converters (DAC). The analog signals are then used to modulate cosine and sine waves at the carrier frequency fc and summed to be transmitted as a s(t) signal.

OFDM receiver At the receiver the signal is converted to a digital through an analog-to-digital converter (ADC) and the guard period is removed. Then, the serial signal is changed to a parallel format obtaining 2N streams. The Fast Fourier Transform (FFT) is used in each symbol to convert the data back to the frequency domain. All sub-carriers are demodulated, so they can be evaluated and converted to the data word. Finally, the data words are combined to the same word size as the original data.

Figure 17. General OFDM receiver. [23]

29 Manhattan College 6. OFDMA

The radio resource is very limited and, therefore, spectrum efficiency is an important issue in mobile radio systems. In mobile wireless communication efficiency is chosen as the basis. It comes up as the necessity to share the spectrum among the maximum possible number of users. Time and bandwidth are used as a measure of spectrum usage, so efficiency is determined by the efficiency of using time-frequency space. There are several multi-user transmission techniques. Usage of a particular transmission method depends on application at hand and the environment in which the system is to operate [26].

OFDMA (Orthogonal Frequency Division Multiple Access) is a multi-version of a digital modulation scheme OFDM that meets the demand for spectrum flexibility. This technique provides easy bandwidth scalability by configuration of the number of subcarriers. Every base station can dynamically adjust to each user the bandwidth usage according to the system requirements [27]. OFDMA allocates a subset of sub-carriers to each user in order to accommodate multiple transmissions simultaneously. The groups of sub-carriers (called sub-channels) do not need to be adjacent, and can be matched to each user to provide the best performance [22].

Sub-carriers Sub-channels OFDM OFDMA

Time Time

Figure 17. Bandwidth allocation OFDM vs. OFDMA.

30 Manhattan College

A problem with OFDMA as compared to OFDM is its high sensitivity to frequency offset. The problem of the orthogonality affects the OFDMA even more because many users transmit simultaneously (each one with their own estimates of the subcarrier frequencies). Hence, if there is a frequency offset it can produce interference by leaking one user’s power into another’s subcarriers bands [28].

Resource blocks The OFDMA symbols are grouped into resource blocks. The resource blocks have a total size of 180KHz in the frequency domain and 0.5ms in the time domain. In this setup, resource blocks are allocated to individual users, in the frequency-time domain. The more resource blocks a user receives and the higher the modulation used in the resource elements, the higher the bit-rate. Which resource blocks and how many the user receives at a given point depend on advanced scheduling mechanisms in the frequency and time dimensions [29].

Figure 18. The LTE downlink physical resource based on OFDMA. [29]

31 Manhattan College 7. MATLAB simulation

The MATLAB simulation consists of the implementation of the OFDM transmitter, the channel where the wave is going to propagate, and the OFDM receiver using the LTE mobile video parameters to represent a similar communication in 4G.

I would like to point out that the implemented code is not a real 4G communication as this technology has a set of features that we are not simulating. The intention is to demonstrate how the technique of OFDM, which is used in the two last generations of wireless communication, can mitigate the multipath effect. We show that the two signals, the transmitted and the received, are alike regardless of the bad influence of the channel on the signal condition. It could be interesting in the future to extend the MATLAB code trying to build and demonstrate other characteristics that the last generation of mobile communication can offer like MIMO processing, for example.

7.1 Channel model

In a radio channel, generally, a transmitted signal is not only distorted by multipath fading but also corrupted by thermal noise, as shown in the next figure.

Radio channel

s(t) h(!;t) r(t)

Impulse response

n(t) Gaussian noise

Figure 20. Radio channel model - Adaptation of [30].

The received signal through the channel is written as

! � � = ℎ �; � � � − � �� + �(�) !!

32 Manhattan College

Where ℎ �; � is the impulse response of the channel and �(�) is an AWGN.

In communications theory, Nakagami distributions, Rician distributions, and Rayleigh distributions are used to model scattered signals that reach a receiver by multiple paths. Depending on the density of the scatter, the signal will display different fading characteristics. Rayleigh and Nakagami distributions are used to model dense scatters, while Rician distributions model fading with a stronger line-of-sight. Nakagami distributions can be reduced to Rayleigh distributions, but give more control over the extent of the fading [31]. Specifically, because of OFDM for each subcarrier band the channel can be considered as slow fading and frequency-nonselective. In this case, the effect of the channel is then modeled as a multiplication of the transmitted signal by a random attenuation, the phase shift can be estimated by the received signal and ideal coherent detection can be achieved [32]. In our simulation of multipath fading for OFDM communication the attenuation has been modeled using the Nakagami distribution, for indoors environments, and the Rician distribution for outdoors environments. In both cases, which has a distribution characterized as Nakagami or Rician.

Nakagami distribution The chosen distribution has been shown to fit both the ambient narrow band noise and the amplitude of the scattered signal. In current wireless communication the main role of the Nakagami model can be summarized as follows: • It describes the amplitude of received signal after maximum ratio diversity combining. • The sum of multiple independent and identically distributed Rayleig-fading signals have a Nakagami distributed signal amplitude. • The Nakagami distribution matches some empirical data better that other models. • Nakagami fading occurs for multipath scattering with relatively large delay-time spreads, with different clusters of reflected waves [33].

33 Manhattan College

Because the MATLAB program cannot generate random samples of Nakagami probability density function (pdf), we have used the gamma distribution to model the channel. Note that if we consider X a Nakagami distribution, then X2 has a gamma distribution. The table below shows the pdf of both Nakagami and gamma distributions, and its mean and variance.

Probability density function Mean Variance f x(x)

2 � ! ! ! 1 ! !!!! ! ! ! Γ(� + ) 1 � � 2 Ω 1 Γ(� + ) Γ � Ω Ω 1 − 2 Nakagami Γ(�) � � Γ(�)

� > 0

�!!! !! ! ! � à � � �� ��! Gamma

� ≥ 0, � > 0, � > 0

Table 3. Nakagami and gamma distributions.

� is the fading parameter, which characterizes the severity of fading and is influenced by the frequency. � = 1 corresponds to Rayleigh fading and when � < 1 fading becomes more severe [34]. Notice that Γ(·) is the Gamma function.

Here there is the relationship of the two distributions we are studying:

� = 2� Ω � = �

In the simulation we have done we have used � = 0,5 that means � = 0,25.

34 Manhattan College

Rician distribution In the previous section we have talked about multipath effect in indoors environments. Here there are also the features of the function that can simulate outdoors fading. We are referring to Rician distribution, and we have simulated this scenario as well.

When there is a dominant stationary (nonfading) signal component present, such as a line-of-sight propagation path, the small-scale fading envelope distribution is Rician. In this situation, random multipath components arriving at different angles are superimposed on a stationary dominant signal. At the output of an envelope detector, this has the effect of adding a dc component to the random multipath.

Just as for the case of detection of a sine wave in thermal noise, the effect of a dominant signal arriving with many weaker multipath signals gives rise to the Rician distribution. As the dominant signal becomes weaker, the composite signal resembles a noise signal which has an envelope that is Rayleigh. Thus, the Rician distribution degenerates to a Rayleigh distribution when the dominant component fades away [35].

Because the MATLAB program cannot generate random numbers of Rician distribution, we have used the Chi-Square distribution to model the channel. Note that if � has a Rician distribution with parameters � and � (non-centrality parameter � ≥ 0 and

! ! scale parameter � > 0, for � > 0 ), then has a non-central Chi-Square distribution !

! ! with two degrees of freedom and non-centrality parameter . ! The table below shows the pdf of both Chi-Square and Rician distributions, and its mean and variance.

35 Manhattan College

Probability density function Mean Variance f x(x)

� �� !!!!! ! ! - ! ! � 1 + � � + � � !" ! ! ! σ! ! σ! ! ! ! �� � !, ! ! −∞ < � < ∞, �! � = � > 0, 2σ! Rician �! ≡ zero-order modified Bessel function of the first kind.

! !! � ! !! � ! ! � � 2� 2!Γ Chi-Square 2

� ≥ 0

Table 4. Rician and Chi-Square distributions.

The Rician distribution is often described in terms of a parameter � which is defined as the ratio between the deterministic signal power and the variance of the

!! multipath. It is given by � = or, in terms of dB: !!!

�! � �� = 10��� �� 2�!

The parameter � is known as the Rician factor and completely specifies the Rician distribution. As � → 0, � → −∞ ��, and as the dominant path decreases in amplitude, the Rician distribution degenerates to a Rayleigh distribution [35]. The figure below shows the Rician pdf.

36 Manhattan College

K = -! dB

K = 6 dB "(r)

Received signal envelope voltage r (volts)

Figure 21. Probability density function of Rician distributions: K–>-∞dB (Rayleigh) and K–>6dB - Adaptation of [35].

In the simulation we have exercised, we have used � = 2 as mentioned before,

!! and = 8. To obtain this value we have assumed � = 6�� as the figure 21 shows, and !! we have computed its value from the definition of the Rician factor:

�! � �� = 10��� �� = 6�� 2�!

�! 0,6 = ��� 2�!

�! 10!,! = 2�!

�! 4 ≈ 2�!

�! 8 ≈ �!

37 Manhattan College

7.2 Simulation results

The simulation results are divided in three parts: the signal that has to be transmitted and its graphics presenting all modifications that the input data has to suffer before arriving to the antenna, the received signal and its steps to reproduce the original signal, and the received signal when there is multipath effect in the channel.

In the table shown below there are the numerical values for the LTE parameters used to simulate the communication with OFDM technique. We assume 5MHz of bandwidth and 2GHz of carrier frequency which is a reasonable frequency for 4G wireless communication in the 1.9GHz band.

Parameters LTE Number of carriers K 600 (MBSFN)

Value of carrier number KMIN 0

Value of carrier number KMAX 600

Duration Tu 133.3 �s (MBSFN)

Carrier frequency fc 2GHz

Table 5. Numerical parameters of LTE.

7.1.1 OFDM transmitter

OFDM spectrum is centered on fc. As we explained above one simple way to achieve the centering is to use a 2N-IFFT and T/2 as the elementary period for baseband signal. Figures 22 and 23 are the outputs of IFFT in time and frequency respectively.

38 Manhattan College

Figure 22. Time response of signals carriers at the output of IFFT.

Figure 23. Frequency response of signals carriers at the output of IFFT.

In order to produce a continuous signal we need to apply an interpolator and a Butterworth filter.

39 Manhattan College

LPF g(t) Butterworth

Interpolator To transform to a (Figure X3) continuous wave (Figure X6)

The impulse response of g(t) is shown in Figure 24, and the time domain and frequency domain outputs are illustrated in Figure 25 and Figure 26. As we expected the graph of figure 25 have little steps, and the frequency response of figure 26 is periodic as required of the frequency response of a discrete-time system.

Figure 24. Impulse response g(t).

40 Manhattan College

Figure 25. Time response at the output of g(t).

Figure 26. Frequency response at the output of g(t).

The Butterworth filter is the type of D/A filter used in this program to reconstruct the signal. It is of order 7 and cut-off frequency approximately 1/T. The output is shown in Figures 28 and 29. Notice that at the beginning of the signal there is a noise for the time response.

41 Manhattan College

Figure 27. Butterworth filter response.

Figure 28. Time response at the output of LPF.

Figure 29. Frequency response at the output of LPF. 42 Manhattan College

The last step to get the transmission signal is to perform the quadrature multiplex amplitude modulation of the output of the DAC. An in-phase signal mI(t) and a quadrature signal mQ(t) are modulated using the formula:

� � = �! � cos 2��!� + �! � sin 2��!�

The complete signal s(t) is illustrated in Figures 30 and 31. Observe that the highest peak in the graph of the frequency domain is the carrier frequency of the transmitted signal.

Figure 30. Time response of signal s(t).

Figure 31. Frequency response of signal s(t).

43 Manhattan College

7.1.2 OFDM receiver

OFDM is very sensitive to timing and frequency offsets. Therefore, we have to consider the delay produced by the filtering operation even thought we are simulating an ideal environment. Taken care of the delay, and knowing that the reception operation uses an envelope detector the rest of the reception process is the reverse of the transmission.

Figure 32. Time response of signal before the ADC.

Figure 33. Frequency response of signal before the ADC.

44 Manhattan College

Figure 34. Time response of signal after LPF filter.

Figure 35. Frequency response of signal after LPF filter.

Figure 36. Time response of signal after sampling.

45 Manhattan College

Figure 37. Frequency response of signal after sampling.

Next figure illustrates the 4-QAM constellation. Some of the symbols are affected by delay produced by the filtering process, so we cannot see them in the position where they should be. However, after the slicer block, which selects the nearest ideal symbol from the 4-QAM constellation, we can see that the received symbols have the position that we expected.

Figure 38. Constellation of signal after FFT.

46 Manhattan College

Figure 39. Constellation of signal after the slicer.

7.1.3 OFDM receiver with multipath channel

In the figures shown below we are going to see how is the signal reception, and consequently the symbols received with multipath effect. Observe that the signal received is not as good as the previous simulation where the wave is perfectly well rounded. We can see the effects of the delay.

Below there are the pictures that confirm the technique of OFDM can mitigate multipath in indoors and outdoors environments.

47 Manhattan College

• Indoors: Nakagami distribution

Figure 40. Time response of signal before the ADC.

Figure 41. Frequency response of signal before the ADC.

48 Manhattan College

Figure 42. Time response of signal after LPF filter.

Figure 43. Frequency response of signal after LPF filter.

Figure 44. Time response of signal after sampling.

49 Manhattan College

Figure 45. Frequency response of signal after sampling.

Notice the difference between the two simulations: signal without being distorted and signal with multipath effect. In the last case the symbols are more scattered in the constellation. Even so, after the slicer block all symbols can be perfectly reconstructed.

Figure 46. Constellation of signal after FFT.

50 Manhattan College

Figure 47. Constellation of signal after the slicer.

• Outdoors: Rician distribution

Figure 48. Time response of signal before the ADC.

51 Manhattan College

Figure 49. Frequency response of signal before the ADC.

Figure 50. Time response of signal after LPF filter.

Figure 51. Frequency response of signal after LPF filter.

52 Manhattan College

Figure 52. Time response of signal after sampling.

Figure 53. Frequency response of signal after sampling.

Figure 54. Constellation of signal after FFT. 53 Manhattan College

Figure 55. Constellation of signal after the slicer.

54 Manhattan College 8. The 6713 DSP Starter Kit (DSK)

The second part of this project consists in try to demonstrate the goodness of OFDM as done in the MATLAB simulation, but this time using hardware. Manhattan College is developing new laboratories in the Electrical Department, so they got many of DSP kits to do it. That is the reason why we decided to transfer the theory studied before to these kits.

8.1 DSK description

The 6713 DSP Starter Kit (DSK) is a low-cost platform, which lets customers evaluate and develop applications for the Texas Instruments C67X DSP family.

Figure 56. Package contents.

TI’s Code Composer Studio development tools are bundled with the 6713 DSK providing the user with an industrial-strength integrated development environment for C and assembly programming. Code Composer Studio communicates with the DSP using an on-board JTAG emulator through a USB interface.

55 Manhattan College

The figure below illustrates the main sections of the board:

Figure 57. Board.

The TMS320C6713 DSP is the heart of the system. It is a core member of Texas Instruments’ C64X line of fixed point DSPs whose distinguishing features are an extremely high performance 225MHz VLIW DSP core and 256Kbytes of internal memory. On-chip peripherals include a 32-bit external memory interface (EMIF) with integrated SDRAM controller, 2 multi-channel buffered serial ports (McBSPs), two on- board timers and an enhanced DMA controller (EDMA). The 6713 represent the high end of TI’s C6700 floating point DSP line both in terms of computational performance and on-chip resources.

DSPs are frequently used in audio processing applications, so the DSK includes an on-board codec called the AIC23. Codec stands for coder/decoder, the job of the AIC23 is to code analog input samples into a digital format for the DSP to process, and then decode data coming out of the DSP to generate the processed analog output.

Hardware overview The main features of the 6713 DSK board are listed below.

56 Manhattan College

Figure 58. Block diagram of the board.

Feature Details 225MHz, floating point, 256Kb internal TMS320C6713 DSP RAM/Cache CPLD Programmable “glue” logic External SDRAM 16Mbytes, 32-bit interface External Flash 512Kbytes, 8-bit interface (256Kb usable) Stereo, 8KHz-96KHz sample rate, 16 to AIC23 Codec 32 bit samples, mic, line-in, line-out and speaker jacks 4 User LEDs Writable through CPLD 4 User DIP Switches Readable through CPLD Selects power-on configuration and boot 3 Configuration Switches modes Allows user to enhance functionally with Daughter card Expansion Interface add-on daughter cards Allows high speed communication with HPI Expansion Interface another DSP Provides high speed JTAG debug through Embedded JTAG Emulator widely accepted USB host interface

Table 6. Main features of the board.

57 Manhattan College

Codec overview The DSK uses a Texas Instruments AIC23 (part #TLV320AIC23) stereo codec for input and output of audio signals. The codec samples analog signals on the microphone or line inputs and converts them into digital data that can be processed by the DSP. When the DSP is finished with the data it uses the codec to convert the samples back into analog signals on the line and headphone outputs so the user can hear the output.

Figure 59. AIC23 Codec.

Software overview Code Composer Studio is TI’s flagship development tool. It consists of an assembler, a C , an integrated development environment (IDE, the graphical interface to the tools) and numerous support utilities like a hex format conversion tool.

The Code Composer IDE is the piece you see when you run Code Composer. It consists of an editor for creating , a project manager to identify the source files and options necessary for your programs and an integrated source level debugger that lets you examine the behavior of your program while it is running. The IDE is responsible for calling other components such as the compiler and assembler so developers don’t have to deal with the hassle of running each tool manually.

The 6713 DSK includes a special device called a JTAG emulator on-board that can directly access the register and memory state of the 6713 chip through a standardized JTAG interface port. When a user wants to monitor the progress of his program, Code Composer sends commands to the emulator through its USB host interface to check on any data the user is interested in [36].

58 Manhattan College

8.2 Results

As the time is limited, there is only the transmitter implementation. To do it, firstly we had to create the video data with one of the kits. Then, once the quadrature data is generated, it goes into another DSK where is transformed (IFFT-D/A filter) to an analog signal which in turn modulates a Radio Frequency carrier.

The block diagram is given below:

DSK 2 DSK 1 OFDM INPHASE

PN SEQ. Sampling IFFT GEN.

QUAD QUAD INPHASE

Radio frequency D/A modulator

DSK 3

Figure 60. Block diagram.

Figure 61. Connection of the two DSK.

59 Manhattan College

Video data The video data is simulated by a pseudorandom sequence generated by programming the Texas Instruments DSK6713. Specifically, the 16 bits shift left register structure shown in the figure below is implemented by the project PNGENSTEREO.C. The code and some more explanations are provided in the Appendix III.

Seed Array

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

XOR XOR XOR

Figure 62. Pseudorandom noise generation diagram using LFSR.

Specifically, the sequences are stored in buffers (One for the quadrature-phase data and the other one for the In-phase data) and binary data is represented by a level of + 8000 converted by the CODEC to a binary signal of + 0.3 V and a rate of 8kbps. The DAC of Codec converts the sequences to the graphs which are provided for both the In- phase and the Quadrature-phase components using the Code Composer Studio, see figures 63 and 65. Also the PNGENSTEREO.C code provides triggering for the Tectronix Oscilloscope.

The sequences have also been captured by connecting a Logic Analyzer at the line-out of the Codec of the DSK6713 (see figure 68).

60 Manhattan College

Figure 63. Signal of the imaginary buffer.

Figure 64. Features of the imaginary signal.

61 Manhattan College

Figure 65. Signal of the real buffer.

Figure 66. Features of the real signal.

62 Manhattan College

Figure 67. PN sequence on the Tectronix Scope.

Figure 68. Measured signal at the Logic Analyzer.

63 Manhattan College

Implementation of OFDM transmitter by programming the TMS320C6713 DSP Video data generated by a DSK6713 serve as input to another DSK which is programmed to produce the OFDM signal. In the project OFDMfft128Ham2 a FFT algorithm has been modified to produce 128 points IFFT and program the DSK accordingly. Only 32 carriers are shown in the figure 69 for the In-phase and Quadrature components. This program works in real time using an input buffer, a processing buffer, and an output buffer. A hamming window1 has been used to reduce the effect of spectral leakage.

The in-phase and the quadrature data go into the line-in of the second DSK and are sampled by the A/D converter of the codec, 1 sample per 0.125ms as the real and imaginary components of a complex signal. Then the IFFT computation unit follows. At the output of the IFFT we are looking at first at the real and imaginary parts of a discrete time signal. Because we are using 128 points transform only the 0- 63 components represent the positive time carriers. The D/A conversion process of the codec converts the discrete signal to an analog signal. This process also includes a low pass reconstruction filter of cut-off frequency half of the sampling frequency, that is, 4kHz.

1 Essentially, an OFDM signal consists of a number of unfiltered QAM subcarriers. To make the spectrum As a result, the out-of-band spectrum decreases rather slowly, according to a sinc function. go down more rapidly, windowing can be applied to the individual OFDM symbols. Windowing an OFDM symbol makes the amplitude go smoothly to zero at the symbol boundaries [6].

64 Manhattan College

Figure 69. Real and Imaginary signal after the IFFT.

Below, in figure 70 are the in-phase and quadrature phase analog signals as generated by the Code Composer studio Graphics. The output of the reconstruction filter of the Codec (the generated analog OFDM signal) is shown at in figure 71 as it has been captured from the screen of the Tectronix scope. Alternative methods to improve the analog signal will be investigated in the future.

65 Manhattan College

Figure 70. Real and Imaginary OFDM signal after interpolation.

66 Manhattan College

Figure 71. Real and Imaginary OFDM signal after the filter.

67 Manhattan College

The last step is the radiofrequency modulation. A DSK has been programmed to multiply the OFDM analog signal which has a bandwidth of 4kHz by a complex carrier. Due to the limitations in the sampling rate of the DSK the carrier frequency has been set to 16kHz.

The input in the third DSK is an analog complex OFDM signal with real and imaginary parts i.e., X.real+jXimag. The real and imaginary parts are entered through the stereo input and buffered. Then they multiply the complex carrier term as

(X.real+jX.imag)(cosωct+jsinωct). What it is transmitted at the output of the codec of the DSK, like in the Matlab program, is the real part or the Imaginary part but not both of the resulting product. i.e., X.real·cos(ωct)- X.imag·sin(ωct). Therefore, we hook up the oscilloscope only at one of the channels of the codec.

The resulting signals are shown in figures 72 and 73.

Figure 72. The In-phase component of the signal at the transmitter output.

68 Manhattan College

Figure 73. The signal at the transmitter output (Tectronix Scope).

69 Manhattan College 9. Conclusion

The main goal of this project was the introduction to the new generation of mobile wireless communication, and the demonstration of its technique of signal transmission and reception against the multipath effect in indoor and outdoor environments.

We analyzed the results that we obtained once research was done, and simulation was implemented. There are four points we should mention in conclusion after studying the standards of 4G and examining the results that we have obtained:

• We conclude that LTE is the standard, at the moment, used mostly in some of the states in the U.S. The biggest and most respectable companies are choosing this candidate of IMT-A to develop the 4G.

• OFDM is the preferred technique to transmit and receive the electrical signal in the 4G of mobile communication even thought the spectrum is going to be shared among many users. We have demonstrated that one of the features that makes OFDM the technique of choice in a new generation is the mitigation against ICI and ISI.

• We have confirmed the theoretical thesis of OFDM with an implementation of its transmitter and its receiver, adding multipath in the channel where the wave is propagated. Although some of the received symbols are dispersed in the constellation, after the slicer the symbols are perfectly recognized.

• Once tried to implement the same software simulation in hardware, we experienced more difficult in programming the TMS320C6713 DSP than Matlab. We can notice in the transmitter of the DSK: after the D/A converter the analog signal is not as smooth as we would like. Still, it can modulate a high frequency carrier for further transmission. Also, there are limitations in the number of subcarriers mainly due to limited memory size.

70 Manhattan College 10. Future lines

In this project we introduce the fourth generation of mobile wireless and its technique of transmission and reception. It can be increased in some different ways:

• It could be interesting demonstrate one of the features that 4G does in the new network of mobile communication. An example can be the Doppler effect; when a user with high mobility (in a car) can receive correctly the video data.

• To have an exactly results, it is a good idea compute the BER (Bit Error Rate) of the symbols received in the OFDM communication in the Matlab simulation. Although there is a slicer after the constellation, the obtained results would be more reliable.

• There is only the transmitter implementation with the DSK, so it can be finished with the OFDM receiver.

• To do the same as the simulation with the Matlab code, once done the transmitter and the receiver operation with the DSK, it can be introduced a multipath effect and see how it works.

71 Manhattan College 11. References

[1] Sajal Kumar Das. Mobile Handset Design. John Wiley & Sons, 2010. [2] Evolución de la Tecnología Móvil: 1G, 2G, 3G, 4G… http://linkea.do/post/5275007504/evolucion-de-la-tecnologia-movil-1g-2g-3g-4g [3] Trillium Digital Systems, Inc. Third Generation (3G) Wireless White Paper. March 2000. http://www.dryaseen.pk/wp_3g.pdf [4] 3G. http://www.wikinvest.com/concept/3G [5] Comunicaciones móviles 3G. http://wikitel.info/wiki/3G [6] Richard Van Nee and Ramjee Prasad. OFDM for wireless multimedia communications. Artech House. [7] Toshio Miki, Tomoyuki Ohya, Hitoshi Yoshimo and Narumi Umeda. The Overview of the 4th Generation Mobile Communication System. NTT DoCoMo Inc., Wireless Labs. [8] Krystian Safjan, Valeria D’Amico, Daniel Bültmann, David Martín-Sacristán, Ahmed Saadani, Hendrik Schöneich. Assessing 3GPP LTE-Advanced as IMT-Advanced Technology: The WINNER + Evaluation Group Approach. IEEE Communications Magazine. February 2001. [9] Kamran Etemad, Max Riegel. Topics and Updates on 4G Technologies. IEEE Communications Magazine. August 2010. [10] http://www.pcmag.com/encyclopedia_term/0,2542,t=cellular+generations&i=55406,00.asp [11] Amitava Ghosh, Rapeepat Ratasuk, Bishwarup Mondal, Nitin Mangalvedhe and Tim Thomas. LTE-Advanced: Next-generation Wireless Broadband Technology. IEEE Wireless communications. June 2010. [12] www.att.com [13] www.verizonwireless.com [14] Top Ten Reviews. http://cell-phone-providers-review.toptenreviews.com/index.html [15] http://toip.uchile.cl/mediawiki/upload/e/e5/AnexoFG-Marcomun.pdf [16] Luna O. Marco A. and Sánchez G. Jaime. CDMA Multiportadora en redes inalámbricas de banda ancha para interiores. CICESE – Depto. De Electrónica y Telecomunicaciones. [17] Advantages and Disadvantages of OFDM. http://sna.csie.ndhu.edu.tw/~cnyang/MCCDMA/tsld021.htm [18] www.wirelessdictionary.com/Wireless-Dictionary-Multipath-Effect-Definition.html

72 Manhattan College

[19] Charan Langton. Inter Symbol Interference (ISI) and Root-raised Cosine (RRC) filtering. www.complextoreal.com [20] R. Kumar and Dr. S. Malarvizhi. Reduction of Intercarrier Interference in OFDM Systems. Department of Electronics and Communications Engineering., SRM University, Chennai. http://www.ubicc.org/files/pdf/ubicc_200_200.pdf [21] HSC Technical Wiki. http://wiki.hsc.com [22] Arun Batra and James R. Zeidler. Narrowband Interference Mitigation in BICM OFDM Systems. Department of Electrical and Computer Engineering. University of California. May 2010. [23] http://en.wikipedia.org [24] Charan Langton. Orthogonal Frequency Division Multiplexing (OFDM). http://www.complextoreal.com/chapters/ofdm2.pdf [25] Uchechi Charles Ogbonna. “WIMAX” THE FUTURE OF WIRELESS COMMUNICATION. Manhattan College Department of Computer and Electrical Engineering. Fall 2010. [26] Asrar U. H. Sheikh. Wireless Communications Theory and Techniques. United States of America 2004. [27] K.N Shantha Kumar, Madhu Kata, Paruchuri Chaitanya, Dinesh Mukkollu. LTE- Advanced: Future of Mobile Broadband. 2009 Tata Consultancy Services. [28] Nima Soltani. Comparison of Single-Carrier FDMA vs. OFDMA as 3GPP Long-Term Evolution Uplink. Autumm 2009. [29] Lionel Fuependap Metuge Reya. 4G Technology Features and Evolution towards IMT-Advanced. Faculty of Electronics, Communications and Automation. Aalto University School of Science and Technology. 2010. [30] Shinsuke Hara and Ramjee Prasad. Multicarrier Techniques for 4G Mobile Communications. Artech House. [31] Matlab toolbox. [32] John Proakis and Masoud Salehi. Digital communications. McGrawHill, fifth edition, p 847. [33] Wireless Communication. http://wireless.per.nl/reference/chaptr03/ricenaka/nakagami.htm [34] Zhengjiu Kang, Kung Yao, and Flavio Lorenzelli. Nakagami-m Fading Modeling in the Frequency Domain for OFDM System Analysis. IEEE Communications letters, Vol. 7, NO. 10. October 2003. [35] Theodore S. Rappaport , Wireless Communications: Principles and Practice, 2e

73 Manhattan College

Prentice Hall, 2002. [36] Texas Instruments 6713 DSP Starter Kit (DSK) Tutorial.

74 Manhattan College 12. Bibliography

o Introduction to Mobile Telephone Systems – 1G, 2G, 2,5G, and 3G Wireless Technologies and Services. http://es.scribd.com/doc/3324514/Introduction-to-Mobile- Telephone-Systems1G-2G-2-5G-and-3G-Wireless-Technologies-and-Services o Sistemas de telecomunicación. www.tel.uva.es/descargar.htm;jsessionid...?id=1434 o Asrar U. H. Sheikh. Wireless Communications Theory and Techniques. United States of America 2004. o Mischa Schwartz. Mobile Wireless Communications. Department of Electrical Engineering. Columbia University. Cambridge 2005. o http://mobiledevdesign.com/tutorials/ofdm-or-ofdma o Rulph Chassaig and Donald Reay. Digital Signal Processing with the TMS320C6713 and TMS320C6416 DSK. Wiley-Interscience, John Wiley & Sons, INC, 2008. o Athanasios Papoulis and S. Unnikrishna Pillai. Probability, Random Variables, and Stochastic Processes. McGrawHill, fourth edition, 2002. o http://temariotic.wikidot.com/1g o www.clipartof.com/portfolio/toonaday/illustration/cartoon-black-and-white-outline- design-of-a-man-talking-and-pointing-1044947.html o www.ipodtotal.com/noticias/altavoz-auriculares-altec-lansing o www.elpatinete.com/dibujos-colorear/dibujos-partes-del-cuerpo-para-colorear-y- pintar.html o www.micropic.es/index.php?Itemid=65&catid=38:tecnicas&id=55:jugando-con- displays-de-7-segmentos&option=com_content&view=article o munkaris.com/425/history-of-mobile-phone o www.movilzona.es/2010/06/07/iphone-4-caracteristicas-oficiales-del-iphone-4/ o www.intersales.com.au/GPSNetwork.aspx o www.educima.com/dibujo-para-colorear-casa-i9454.html o http://all-free-download.com/free-vector/vector-clip- art/boort_art_deco_empire_state_building_clip_art_15559.html o www.easyvectors.com/browse/other/oak-tree-clip-art

75 Manhattan College

APPENDIX I: Matlab code

OFDM transmitter ‐ OFDM receiver

%LTE-A TRANSMISSION

%Video Transmission %The available bandwidth is 5 MHz clear all; close all;

%Parameters

Tu=133.3e-6; %useful OFDM symbol duration T=Tu/(2*4096); %baseband elementary period G=0; %choice of 1/4, 1/8, 1/16, and 1/32 delta=G*Tu; %guard band duration Ts=delta+Tu; %total OFDM symbol period Kmax=600; %number of usable subcarriers per 5 MHz BW Kmin=0; FS=2*8192; %IFFT/FFT length q=32; %carrier period to elementary period ratio fc=q*1/T; %carrier frequency Rs=4*fc; %simulation period t=0:1/Rs:Tu;

%Data generator

M=Kmax; rand('state',0); a=-1+2*round(rand(M,1)).'+1i*(-1+2*round(rand(M,1))).'; A=length(a); info=zeros(FS,1); info(1:(A/2)) = ( a(1:(A/2)).'); %Zero padding info((FS-((A/2)-1)):FS) = ( a(((A/2)+1):A).');

%Subcarriers generation carriers=FS.*ifft(info,FS); tt=0:T/2:Tu; figure(1); subplot(211); stem(tt(1:80),real(carriers(1:80))); subplot(212); stem(tt(1:80),imag(carriers(1:80))); figure(2);

1 Manhattan College f=(2/T)*(1:(FS))/(FS); subplot(211); plot(f,abs(fft(carriers,FS))/FS); subplot(212); pwelch(carriers,[],[],[],2/T);

% D/A simulation

L = length(carriers); chips = [ carriers.';zeros((2*q)-1,L)]; p=1/Rs:1/Rs:T/2; g=ones(length(p),1); %pulse shape figure(3); stem(p,g); dummy=conv(g,chips(:)); u=(dummy(1:length(t))); figure(4); subplot(211); plot(t(1:5300),real(u(1:5300))); subplot(212); plot(t(1:5300),imag(u(1:5300))); figure(5); ff=(Rs)*(1:(q*FS))/(q*FS); subplot(211); plot(ff,abs(fft(u,q*FS))/FS); subplot(212); pwelch(u,[],[],[],Rs); u=[dummy; zeros(46,1)]; [b,a] = butter(7,1/40); %reconstruction filter [H,F] = FREQZ(b,a,FS,Rs); figure(6); plot(F,20*log10(abs(H))); uoft = filter(b,a,u); %baseband signal figure(7); subplot(211); plot(t(1:5300),real(uoft(1:5300))); subplot(212); plot(t(1:5300),imag(uoft(1:5300))); figure(8); subplot(211); plot(ff,abs(fft(uoft,q*FS))/FS); subplot(212); pwelch(uoft,[],[],[],Rs);

%Upconverter delay=95; %Reconstruction filter delay s_tilde=(uoft(delay+(1:length(t))).').*exp(1i*2*pi*fc*t); s=real(s_tilde); %passband signal figure(9); plot(t(1:5300),s(1:5300));

2 Manhattan College figure(10); subplot(211); plot(ff,abs(fft(s,q*FS))/FS); subplot(212); pwelch(s,[],[],[],Rs);

%------

%LTE-A RECEPTION

%Video Reception

%Parameters tt=0:T/2:Tu;

%Data generator sM = 2; [x,y] = meshgrid((-sM+1):2:(sM-1),(-sM+1):2:(sM-1)); alphabet = x(:) + 1i*y(:);

%OFDM RECEPTION %Downconversion r_tilde=exp(-1i*2*pi*fc*t).*s; figure(11); subplot(211); plot(t,real(r_tilde)); axis([0e-7 6.5e-7 -40 40]); grid on; figure(11); subplot(212); plot(t,imag(r_tilde)); axis([0e-7 6.5e-7 -30 10]); grid on; figure(12); ff=(Rs)*(1:(q*FS))/(q*FS); subplot(211); plot(ff,abs(fft(r_tilde,q*FS))/FS); grid on; figure(12); subplot(212); pwelch(r_tilde,[],[],[],Rs);

%Carrier suppression

[B,AA] = butter(7,1/4); r_info=2*filter(B,AA,r_tilde); %Baseband signal continuous-time figure(13);

3 Manhattan College subplot(211); plot(t,real(r_info)); axis([0 7e-7 -40 40]); grid on; figure(13); subplot(212); plot(t,imag(r_info)); axis([0 7e-7 -30 10]); grid on; figure(14); f=(2/T)*(1:(FS))/(FS); subplot(211); plot(ff,abs(fft(r_info,q*FS))/FS); grid on; subplot(212); pwelch(r_info,[],[],[],Rs);

%Sampling r_data=real(r_info(1:(2*q):length(t)))... %Baseband signal, discretetime +1i*imag(r_info(1:(2*q):length(t))); figure(15); subplot(211); stem(tt(1:85),real(r_data(1:85))); subplot(212); stem(tt(1:85),imag(r_data(1:85))); figure(16); f=(2/T)*(1:(FS))/(FS); subplot(211); plot(f,abs(fft(r_data,FS))/FS); grid on; subplot(212); pwelch(r_data,[],[],[],2/T);

%FFT info_2N=(1/FS).*fft(r_data,FS); info_h=[info_2N(1:(A/2)) info_2N((FS-((A/2)-1)):FS)];

%Slicing for k=1:M, a_hat(k)=alphabet((info_h(k)-alphabet)==min(info_h(k)-alphabet)); end; figure(17); plot(info_h((1:A)),'.k'); title('info-h Received Constellation') axis square; axis equal;

4 Manhattan College figure(18); plot(a_hat((1:A)),'or'); title('a_hat 4-QAM') axis square; axis equal; grid on; axis([-1.5 1.5 -1.5 1.5]);

Multipath effect (Nakagami)

% CHANNEL

%Multipath (indoors) h_sqr=gamrnd(0.5,1,[1 length(t)]); h=sqrt(h_sqr); s_tilde=s_tilde.*h; s=real(s_tilde);

Multipath effect (Rician)

% CHANNEL

%Multipath (outdoors) h_sqr=ncx2rnd(2,8,[1 length(t)]); h=sqrt(h_sqr); h_multiply=h*0.5; s_tilde=s_tilde.*h; s=real(s_tilde);

5 Manhattan College

APPENDIX II: Multipath effect in outdoors (Rayleigh)

In the report we have talked about multipath effect in outdoors environments, and we have simulated it with Rician distribution. Because Rayleigh distribution is more appropriate for wireless communications, we have simulated this scenario as well. As we have mentioned in the report, Rician distribution is used when there is a dominant path present, but when it becomes weaker the Rician distribution degenerates to a Rayleigh distribution. When the parameter � → 0, the Rician factor � → −∞ ��, and the dominant path decreases in amplitude:

�! � �� = 10��� �� → −∞ 2�!

�! ��� �� → −∞ 2�!

�! → 0 2�!

�! → 0 �!

To simulate this scenario we have used the same code as the exercised with the

!! Rician distribution. The only parameter that changes is . !!

Below there are the pictures and the Matlab code that confirm the technique of OFDM can also mitigate multipath in outdoors when there is not a dominant path.

1 Manhattan College

Reception

Figure 1. Time response of the signal before the ADC.

Figure 2. Frequency response of the signal before the ADC.

2 Manhattan College

Figure 3. Time response of the signal after LPF filter.

Figure 4. Frequency response of the signal after LPF filter.

3 Manhattan College

Figure 5. Time response of the signal after sampling.

Figure 6. Frequency response of the signal after sampling.

4 Manhattan College

Figure 7. Constellation of the signal after the FFT.

Figure 8. Constellation of the signal after the slicer.

5 Manhattan College

Multipath effect (Rayleigh)

% CHANNEL

%Multipath (outdoors) h_sqr=ncx2rnd(2,0,[1 length(t)]); h=sqrt(h_sqr); h_multiply=h*0.5; s_tilde=s_tilde.*h; s=real(s_tilde);

6 Manhattan College

APPENDIX III: CODE FOR THE OFDM TRANSMITTER IMPLEMENTATION

1. Generation of the Video Data ...... 1 PNGENSTEREO.c ...... 2 Noise_gen.h header ...... 4 2. OFDM Signal Generation ...... 4 OFDM c-Program ...... 5 fft.h complex FFT function ...... 7 Hamming Window ...... 9 Impulse response of a low pass filter with cut-of frequency of 4kHz ...... 10 3. OFDM Signal Radio Frequency Modulation ...... 11 OFDMTRANSMITTER2.c ...... 11

1. Generation of the Video Data

A pseudorandom sequence is used to model coded video data. An initial 16-bit seed is assigned to a register. Bits b0, b1, b11, and b13 are XORed and the result is placed into a feedback variable. The register with the initial seed value is then shifted one bit to the left. The feedback variable is then assigned to bit b0 of the register. A scaled minimum or maximum is assigned to prnseq, depending on whether the register’s bit b0 is zero or 1. This scaled value corresponds to the noise-level amplitude. The header file noisegen.h defines the shift register bits. Two sequences are generated: One for the in-phase and the other for the quadrature components of the QAM data and presented at the D/A converter of the Codec. One sequence appears at the left channel and the other at the right channel of the output. The generated sequence and the output of the D/A converter as they have been captured by the scope are depicted in the report. For further details refer to the code below. The code for the header file noisegen.h is also provided.

1 Manhattan College

PNGENSTEREO.c

#include "DSK6713_AIC23.h" // codec support Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate #define DSK6713_AIC23_INPUT_MIC 0x0015 #define DSK6713_AIC23_INPUT_LINE 0x0011 Uint16 inputsource=DSK6713_AIC23_INPUT_LINE; // select line in #define LEFT 0 #define RIGHT 1 union {Uint32 uint; short channel[2];} AIC23_data;

#include "noise_gen.h" //support file for noise generation

#define WLENGTH 128 //Length of data #define NOISELEVEL 8000 #define BUFSIZE 128 #define TRIGGER 32000 //For providing trigger signal to the scope. #include

// Create an Array to plot the output int REALBUFF[BUFSIZE]; int IMAGBUFF[BUFSIZE]; int buf_ptr = 0; int fb1,fb2; //feedback variable shift_reg sreg1; shift_reg sreg2; //shift register int prandRe(void) //gen pseudo-random sequence {-1,1} { int prnseq1; if(sreg1.bt.b0) prnseq1 = -NOISELEVEL; //scaled negative noise level else prnseq1 = NOISELEVEL; //scaled positive noise level fb1 =(sreg1.bt.b0)^(sreg1.bt.b1); //XOR bits 0,1 fb1^=(sreg1.bt.b11)^(sreg1.bt.b13); //with bits 11,13 -> fb1 sreg1.regval<<=1; sreg1.bt.b0=fb1; //close feedback path return prnseq1; //return noise sequence value }

int prandIm(void) //gen pseudo-random sequence {-1,1} { int prnseq2;

2 Manhattan College

if(sreg2.bt.b0) prnseq2 = -NOISELEVEL; //scaled negative noise level else prnseq2 = NOISELEVEL; //scaled positive noise level fb2 =(sreg2.bt.b0)^(sreg2.bt.b1); //XOR bits 0,1 fb2^=(sreg2.bt.b11)^(sreg2.bt.b13); //with bits 11,13 -> fb sreg2.regval<<=1; sreg2.bt.b0=fb2; //close feedback path return prnseq2; //return noise sequence value }

interrupt void c_int11() //interrupt service routine { REALBUFF[buf_ptr]=prandRe();//geverate PN bit IMAGBUFF[buf_ptr]=prandIm();

AIC23_data.channel[RIGHT]=REALBUFF[buf_ptr]; //for right channel; AIC23_data.channel[LEFT]= IMAGBUFF[buf_ptr]; //for left channel; output_sample(AIC23_data.uint); //output to both channels if (++buf_ptr>=BUFSIZE) { buf_ptr=0; AIC23_data.channel[RIGHT]= TRIGGER;// rigger scope for right channel AIC23_data.channel[LEFT]=TRIGGER; //for leftchannel output_sample(AIC23_data.uint); //output to both channels } return; } void main(){ sreg1.regval=0xFFFF; sreg2.regval=0xFFFF; //initial seed value fb1= 1; fb2=1; //initial feevack value comm_intr(); //init DSK, codec, McBSP while (1); //infinite loop }

3 Manhattan College

Noise_gen.h header

//Noise_gen.h header file for pseudo-random noise sequence typedef struct BITVAL //register bits to be packed as integer { unsigned int b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1; unsigned int b7:1, b8:1, b9:1, b10:1, b11:1, b12:1,b13:1; unsigned int dweebie:2; //Fills the 2 bit hole - bits 14-15 } bitval; typedef union SHIFT_REG { unsigned int regval; bitval bt; } shift_reg;

2. OFDM Signal Generation

The in-phase and quadrature phase components represent the real and the imaginary input data to a 128 points IFFT algorithm to generate the OFDM signal. The analog OFDM signal appears at the stereo output of the codec. One channel represents the in-phase and the other the quadrature phase signal.

Specifically, the IFFT algorithm process blocks or frames of samples. Using the IFFT in a real-time program therefore requires a Frame-based processing which divides continuous sequences of input and output samples into frames of N ( =128)samples. A new frame of N input samples must be processed every N sampling instants. Frame- based processing consists of three activities. While a new frame of input samples is being collected a previously collected frame of input samples must be processed and a frame previously processed samples must be output. The basic rate of one sample per sampling instant must be observed by both the input and output activities. Effectively, input, output, and processing activities must take place concurrently and each must operate on a different frame of samples. A widely used method of implementing this is to use three separate buffers—one for input, another for processing, and a third for output. An important real-time constraint on the three activities is that input and output activities must take place on a sample-by-sample basis at each and every sampling instant. In

4 Manhattan College between dealing with this, the processor can process the intermediate frame of samples. Another real-time constraint is that in the time taken to collect a complete frame of input samples, and to output a complete frame of previously processed samples (i.e., N sampling instants), processing of the intermediate frame of samples must be completed. Each time a new frame of input samples has been collected (i.e., every N sampling instants), the frames exchange roles. The frame of input samples that has just been collected becomes the intermediate frame of samples to be processed during the next N sampling instants. The intermediate frame of samples processed during the previous N sampling instants becomes the frame of samples to be output during the next N sampling instants and the frame of samples output during the previous N sampling instants becomes the frame into which new input samples will be written during the next N sampling instants. For efficiency, instead of using three arrays, pointers are dedicated to each of the three activities and exchange their values every N sampling instants. Input and output occurs in sample-by-sample basis in an interrupt service routine while processing takes place in the main body of the program. Below is the code for the OFDM implementation and other programs that are needed.

OFDM c-Program //OFDMfft128cHam.c

#include "DSK6713_AIC23.h" //codec-DSK interface support Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate #include "lp6545.cof" #define DSK6713_AIC23_INPUT_MIC 0x0015 #define DSK6713_AIC23_INPUT_LINE 0x0011 Uint16 inputsource=DSK6713_AIC23_INPUT_LINE; #define LEFT 0 #define RIGHT 1 union {Uint32 uint; short channel[2];} AIC23_data;

#include #include "fft.h" #define PI 3.14159265358979 #define TRIGGER 32000 //for providing trigger to the scope #define N1 128 #include "hamm128.h" int k; short buffercount = 0; //number of new input samples in iobuffer

5 Manhattan College short bufferfull = 0; //set by ISR to indicate iobuffer full // For alternating Real and imaginary Input COMPLEX A[N1], B[N1], C[N1]; COMPLEX *input_ptr, *output_ptr, *process_ptr, *temp_ptr; COMPLEX twiddle[N1]; short outbufferre[N1]; // real part of the transform short outbufferim[N1]; //imaginary part of the transform

interrupt void c_int11(void) //ISR { if (k==0) // for real part input or output { AIC23_data.channel[RIGHT]= (((short)((output_ptr + buffercount)- >real))); outbufferre[buffercount] = (short)(((output_ptr + buffercount)- >real)); (input_ptr + buffercount)->real =500*((float)(input_left_sample()))*hamming[buffercount]; k=1; } if (k==1) //for imaginary part input or output {

AIC23_data.channel[LEFT]=((short)((output_ptr + buffercount)->imag)); output_sample(AIC23_data.uint); //output to both channels outbufferim[buffercount] = (short)((output_ptr + buffercount)->imag); (input_ptr + buffercount++)->imag = 500*( (float)(input_right_sample()))*hamming[buffercount]; k=0; } if (buffercount >= N1) //for overlap-add method iobuffer { // is half size of FFT used buffercount = 0; bufferfull = 1; } }

main() { int n; for (n=0 ; n

6 Manhattan College

input_ptr = A; output_ptr = B; process_ptr = C; k=0; comm_intr(); //initialise DSK, codec, McBSP while(1) //frame processing loop { while(bufferfull==0); //wait for new frame of input samples bufferfull = 0;

temp_ptr = process_ptr; //rotate buffer/frame pointers process_ptr = input_ptr; input_ptr = output_ptr; output_ptr = temp_ptr;

fft(process_ptr,N1,twiddle); //process contents of buffer

for (n=0 ; n

(process_ptr+n)->real =((process_ptr+n)->real) /(N1*16.0);//modified for IFFT (process_ptr+n)->imag=((process_ptr+n)->imag) /(N1*16.0); } (process_ptr)->real = TRIGGER; // add oscilloscope trigger pluse (process_ptr)->imag= TRIGGER;

} //end of while(1) } //end of main()

fft.h complex FFT function //fft.h complex FFT function taken from Rulph's C31 book //this file contains definition of complex dat structure also struct cmpx //complex data structure used by FFT { float real; float imag; }; typedef struct cmpx COMPLEX; void fft(COMPLEX *Y, int M, COMPLEX *w) //input sample array, number of points { COMPLEX temp1,temp2; //temporary storage variables int i,j,k; //loop counter variables int upper_leg, lower_leg; //index of upper/lower butterfly leg int leg_diff; //difference between upper/lower leg

7 Manhattan College

int num_stages=0; //number of FFT stages, or iterations int index, step; //index and step between twiddle factor i=1; //log(base 2) of # of points = # of stages do { num_stages+=1; i=i*2; } while (i!=M);

leg_diff=M/2; //starting difference between upper & lower legs step=2; //step between values in twiddle.h for (i=0;i

(Y[lower_leg]).imag=temp2.real*(w[index]).imag+temp2.imag*(w[index]).r eal; (Y[upper_leg]).real=temp1.real; (Y[upper_leg]).imag=temp1.imag; } index+=step; } leg_diff=leg_diff/2; step*=2; } j=0; for (i=1;i<(M-1);i++) //bit reversal for resequencing data*/ { k=M/2; while (k<=j) { j=j-k; k=k/2; } j=j+k; if (i

8 Manhattan College

(Y[j]).real=(Y[i]).real; (Y[j]).imag=(Y[i]).imag; (Y[i]).real=temp1.real; (Y[i]).imag=temp1.imag; } } return; } //end of fft()

Hamming Window float hamming[] = {

8.0000000e-002, 8.0562849e-002, 8.2250017e-002, 8.5057376e-002,

8.8978056e-002, 9.4002462e-002, 1.0011830e-001, 1.0731060e-001,

1.1556177e-001, 1.2485160e-001, 1.3515738e-001, 1.4645387e-001,

1.5871343e-001, 1.7190607e-001, 1.8599949e-001, 2.0095922e-001,

2.1674863e-001, 2.3332909e-001, 2.5066003e-001, 2.6869903e-001,

2.8740195e-001, 3.0672302e-001, 3.2661496e-001, 3.4702909e-001,

3.6791545e-001, 3.8922293e-001, 4.1089938e-001, 4.3289177e-001,

4.5514627e-001, 4.7760842e-001, 5.0022325e-001, 5.2293542e-001,

5.4568935e-001, 5.6842936e-001, 5.9109980e-001, 6.1364519e-001,

6.3601036e-001, 6.5814057e-001, 6.7998167e-001, 7.0148022e-001,

7.2258359e-001, 7.4324016e-001, 7.6339936e-001, 7.8301186e-001,

8.0202967e-001, 8.2040626e-001, 8.3809664e-001, 8.5505753e-001,

8.7124742e-001, 8.8662669e-001, 9.0115771e-001, 9.1480492e-001,

9.2753491e-001, 9.3931655e-001, 9.5012099e-001, 9.5992179e-001,

9.6869497e-001, 9.7641907e-001, 9.8307517e-001, 9.8864700e-001,

9.9312091e-001, 9.9648596e-001, 9.9873391e-001, 9.9985927e-001,

9.9985927e-001, 9.9873391e-001, 9.9648596e-001, 9.9312091e-001,

9.8864700e-001, 9.8307517e-001, 9.7641907e-001, 9.6869497e-001,

9.5992179e-001, 9.5012099e-001, 9.3931655e-001, 9.2753491e-001,

9 Manhattan College

9.1480492e-001, 9.0115771e-001, 8.8662669e-001, 8.7124742e-001,

8.5505753e-001, 8.3809664e-001, 8.2040626e-001, 8.0202967e-001,

7.8301186e-001, 7.6339936e-001, 7.4324016e-001, 7.2258359e-001,

7.0148022e-001, 6.7998167e-001, 6.5814057e-001, 6.3601036e-001,

6.1364519e-001, 5.9109980e-001, 5.6842936e-001, 5.4568935e-001,

5.2293542e-001, 5.0022325e-001, 4.7760842e-001, 4.5514627e-001,

4.3289177e-001, 4.1089938e-001, 3.8922293e-001, 3.6791545e-001,

3.4702909e-001, 3.2661496e-001, 3.0672302e-001, 2.8740195e-001,

2.6869903e-001, 2.5066003e-001, 2.3332909e-001, 2.1674863e-001,

2.0095922e-001, 1.8599949e-001, 1.7190607e-001, 1.5871343e-001,

1.4645387e-001, 1.3515738e-001, 1.2485160e-001, 1.1556177e-001,

1.0731060e-001, 1.0011830e-001, 9.4002462e-002, 8.8978056e-002,

8.5057376e-002, 8.2250017e-002, 8.0562849e-002, 8.0000000e-002

};

Impulse response of a low pass filter with cut-of frequency of 4kHz

// lp6545.cof // this file was generated automatically using function dsk_fir67.m

#define N 65 float h[N] = { 7.5648E-004,-1.3200E-004,-9.4218E-004,-1.7130E-004,1.2430E- 003,7.1856E-004, -1.5595E-003,-1.6596E-003,1.6732E-003,3.0589E-003,-1.2712E-003,- 4.8358E-003, 6.3817E-018,6.7228E-003,2.4594E-003,-8.2530E-003,-6.3117E-003,8.7754E- 003, 1.1578E-002,-7.4837E-003,-1.8056E-002,3.4245E-003,2.5312E-002,4.6002E- 003, -3.2728E-002,-1.8480E-002,3.9574E-002,4.2551E-002,-4.5116E-002,- 9.2624E-002, 4.8725E-002,3.1355E-001,4.4980E-001,3.1355E-001,4.8725E-002,-9.2624E- 002,

10 Manhattan College

-4.5116E-002,4.2551E-002,3.9574E-002,-1.8480E-002,-3.2728E- 002,4.6002E-003, 2.5312E-002,3.4245E-003,-1.8056E-002,-7.4837E-003,1.1578E-002,8.7754E- 003, -6.3117E-003,-8.2530E-003,2.4594E-003,6.7228E-003,6.3817E-018,- 4.8358E-003, -1.2712E-003,3.0589E-003,1.6732E-003,-1.6596E-003,-1.5595E- 003,7.1856E-004, 1.2430E-003,-1.7130E-004,-9.4218E-004,-1.3200E-004,7.5648E-004 };

3. OFDM Signal Radio Frequency Modulation

The OFDM analog signal which has a bandwidth of 4kHz is multiplied by a complex carrier. Due to the limitations in the sampling rate of the DSK the carrier frequency has been set to 16kHz. The code is provided below:

OFDMTRANSMITTER2.c

#include "DSK6713_AIC23.h" //codec-DSK interface support Uint32 fs=DSK6713_AIC23_FREQ_32KHZ; //set sampling rate #define DSK6713_AIC23_INPUT_MIC 0x0015 #define DSK6713_AIC23_INPUT_LINE 0x0011 Uint16 inputsource=DSK6713_AIC23_INPUT_LINE; #define LEFT 0 #define RIGHT 1 union {Uint32 uint; short channel[2];} AIC23_data;

#include #include "fft.h" #define PI 3.14159265358979 #define TRIGGER 32000 #define N 512 #include "hamm128.h" int L; short buffercount = 0; //number of new input samples in iobuffer short bufferfull = 0; //set by ISR to indicate iobuffer full COMPLEX A[N], B[N], C[N]; COMPLEX *input_ptr, *output_ptr, *process_ptr, *temp_ptr; COMPLEX twiddle[N]; short outbufferre[N]; short outbufferim[N];

11 Manhattan College

void modulation(COMPLEX *x, COMPLEX *w) { COMPLEX result[N]; int k,n;

for (k=0 ; k

for (k=0 ; kreal))); outbufferre[buffercount] = (short)(((output_ptr + buffercount)- >real)); (input_ptr + buffercount)->real =500*((float)(input_left_sample()))*hamming[buffercount]; L=1; } if (L==1) {

AIC23_data.channel[LEFT]=((short)((output_ptr + buffercount)->imag));

output_sample(AIC23_data.uint); //output to both channels outbufferim[buffercount] = (short)((output_ptr + buffercount)->imag); (input_ptr + buffercount++)->imag = 500*( (float)(input_right_sample()))*hamming[buffercount]; L=0; } if (buffercount >= N) //for overlap-add method iobuffer { // is half size of FFT used buffercount = 0; bufferfull = 1; }

12 Manhattan College

} main() { int n;

for (n=0 ; n

temp_ptr = process_ptr; //rotate buffer/frame pointers process_ptr = input_ptr; input_ptr = output_ptr; output_ptr = temp_ptr;

modulation(process_ptr,twiddle); //process contents of buffer

for (n=0 ; n

(process_ptr+n)->real =((process_ptr+n)->real); (process_ptr+n)->imag=((process_ptr+n)->imag);

} (process_ptr)->real =TRIGGER; // add oscilloscope trigger pluse (process_ptr)->imag =TRIGGER; } //end of while(1) } //end of main()

13 Manhattan College

APPENDIX IV: DSK Supporting Files

Building Projects and the DSK Supporting Files.

Below are the procedure for building projects with the TMS320C6713 DSK and some supporting files. Supporting libraries are only available after installation of the pertaining software and hardware in a PC.

Creating a New Project The following types of files are in the project folder:

• .lib This library provides runtime support for the target DSP chip

• .c This file contains source code that provides the main functionality of this project

• .h This file declares the buffer C-structure as well as define any required constants

• .pjt This file contains all of your project build and configuration options

• .asm This file contains assembly instructions

• .cmd This file maps sections to memory

1. By double-clicking the Code Composer Studio icon on your desktop the following window comes up:

1 Manhattan College

2. Create a new project file PROJECTNAME.pjt in c:\CCStudio_v3.1\MyProjects\ PROJECTNAME by selecting Project →New.

3. In the Project Name field, type PROJECTNAME . In the Location field type C:\CCStudio_v3.1\MyProjects\ PROJECTNAME, if it is not already there. 4. In the Project Type field, select Executable (.out). 5. In the Target field, select your target configuration (TMS320C67xx) and click Finish. 6. The Code Composer Studio™ Program creates a project file called PROJECTNAME.pjt. This file stores your project settings and references the various files used by your project.

Creating and Adding Files to a Project 1. Now to create a c source file, from file menu chose new file→source file. In the edit screen that pops up, you can type your code. Click save as c/c++ type C:\CCStudio_v3.1\MyProjects\ PROJECTNAME in the directory under the name PROJECTNAME.c.

2. To add the file you have just created in the project choose Project®Add Files to Project. Check the c++/C type and select PROJECTNAME.c from the C:\CCStudio_v3.1\MyProjects\PROJECTNAME and click Open. You can also add files to the project by right-clicking on the Project View icon and choosing Add Files to Project or by dragging and dropping files into folders in the Project View window.

2 Manhattan College

3. Add the source file c67l3dskinit.c to the project. c67l3dskinit . c contains the function definitions for a number of low level routines including comm._intr () and output files. This source file is stored in the folder c:\CCStudio_v3.10\MyProjects \Support Select Project—Add Files to Project and look for Files of Type C Source Files (*.c, *.ccc). Open, or double-click on, c67l3dskinit . c. It should appear in the Project View window in the Source folder.

4. Add the source file vectors__intr.asm to the project. Because this program uses interrupt driven input/output, vectors_intr.asm contains the interrupt service table for the C6713 that associates the interrupt service routine c_int11() with the hardware interrupt INT11, which is asserted by the AIC23 codec on the DSK at each sampling instant. This source file is stored in the folder c:\CCStudio_v3.10\MyProjects \Support Select Project→Add Files to Project and look for Files of Type ASM Source Files (*.a*). Open, or double-click on, vectors_intr. asm. It should appear in the Project View window in the Source folder.

5. Add library support files rts6700. lib, dsk67l3bsl . lib, and csl 6713. lib to the project, following the procedure: Three more times, select Project→Add Files to Project and look for Files of Type Object and Library Files (*.o*, *.l*) The three library files are stored in folders c:\CCStudio_v3.l\c6000\cgtools\lib, c:\ CCStudio_v3 .l\c6000\dsk6713\lib, and c:\ccstudio_v3 .l\c6000\csl\ lib, respectively. These are the run-time support (for C67x architecture), board support (for C6713 DSK), and chip support (for C6713 processor) library files.

6. Add the linker command file c67 l3dsk.cmd to the project. This file is stored in the folder c:\CCStudio_v3.10\MyProjects \Support. Select Project→Add Files to Project and look for Files of Type Linker Command File (*.cmd,.*. lcf). Open, or double-click on, c67l3dsk.cmd. It should then appear in the Project View window.

7. No header files will be shown in the Project View window at this stage. Selecting Project→Scan All File Dependencies will rectify this. You should now be able to see header files c67l3dskinit .h, dsk6713 .h, and dsk6713_aic23.h, in the Project View window.

3 Manhattan College

Code Generation and Build Options

The code generation tools underlying CCS, that is, C compiler, assembler, and linker, have a number of options associated with each of them. These options must be set appropriately before attempting to build a project. Once set, these options will be stored in the project file.

Setting Compiler Options Select Project→Build Options and click on the Compiler tab. Set the following options, as shown in Figures below. In the Basic category set Target Version to C671x (-mv6 710). In the Advanced category set Memory Models to Far (—mem_model:data=far).

4 Manhattan College

In the Preprocessor category set Pre-Define Symbol to CHJP_6713 and Include Search Path to c:\CCStudiov3.1\C6000\dsk6713\include; c:\CCStudio_v3.10\MyProjects \Support

Setting Linker Options

Click on the Linker tab in the Build Options window, as shown in the figure below. The Output Filename should default to .\Debug\PROJECTNAME. out based on the name of the project file and the Autoinit Model should default to Run-Time Autoinitialization. Set the following options (all in the Basic category). Set Library Search Path to c:\CCStudio v3.1\C6000\dsk6713\lib and set Include Libraries to rts6700.lib; dsk67l3bsl.lib;csl6713.lib. The map file can provide useful information for debugging (memory locations of functions, etc.). The —c option is used to initialize variables at run time, and the —o option is to name the linked executable output file loop_buf.out. Click on OK.

5 Manhattan College

To build the project select Project→Rebuild All. This compiles and assembles all the C files using cl6x and assembles the assembly file vectors_intr. asm using asrn6x. The resulting object files are then linked with the library files using lnk6x. This creates an executable file PROJECTNAME. out that can be loaded into the C6713 processor and run.

Supporting DSK code

The following files can be stored in the support folder.

C6713dskinit.c Includes functions from TI in the C6713 CSL and C6713DSK BSL

//C6713dskinit.c Includes functions from TI in the C6713 CSL and C6713DSK BSL

#include "C6713dskinit.h" #define using_bios //if BIOS don't use top of vector table extern Uint32 fs; //for sampling frequency extern Uint16 inputsource; void c6713_dsk_init() //dsp-peripheral initialization { DSK6713_init(); //call BSL to init DSK-EMIF,PLL) hAIC23_handle=DSK6713_AIC23_openCodec(0, &config);//handle(pointer) to codec DSK6713_AIC23_setFreq(hAIC23_handle, fs); //set sample rate

6 Manhattan College

DSK6713_AIC23_rset(hAIC23_handle, 0x0004, inputsource); // choose mic or line in MCBSP_config(DSK6713_AIC23_DATAHANDLE,&AIC23CfgData);//interface 32 bits toAIC23

MCBSP_start(DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START | MCBSP_RCV_START | MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC, 220);//start data channel again } void comm_poll() //added for communication/init using polling { poll=1; //1 if using polling c6713_dsk_init(); //init DSP and codec } void comm_intr() //for communication/init using interrupt { poll=0; //0 since not polling IRQ_globalDisable(); //disable interrupts c6713_dsk_init(); //init DSP and codec CODECEventId=MCBSP_getXmtEventId(DSK6713_AIC23_codecdatahandle); //McBSP1 Xmit

#ifndef using_bios //do not need to point to vector table IRQ_setVecs(vectors); //point to the IRQ vector table #endif //since interrupt vector handles this

IRQ_map(CODECEventId, 11); //map McBSP1 Xmit to INT11 IRQ_reset(CODECEventId); //reset codec INT 11 IRQ_globalEnable(); //globally enable interrupts IRQ_nmiEnable(); //enable NMI interrupt IRQ_enable(CODECEventId); //enable CODEC eventXmit INT11

output_sample(0); //start McBSP interrupt outputting a sample } void output_sample(int out_data) //for out to Left and Right channels { short CHANNEL_data;

AIC_data.uint=0; //clear data structure

7 Manhattan College

AIC_data.uint=out_data; //32-bit data -->data structure

//The existing interface defaults to right channel. To default instead to the //left channel and use output_sample(short), left and right channels are swapped //In main source program use LEFT 0 and RIGHT 1 (opposite of what is used here) CHANNEL_data=AIC_data.channel[RIGHT]; //swap left and right channels AIC_data.channel[RIGHT]=AIC_data.channel[LEFT]; AIC_data.channel[LEFT]=CHANNEL_data; if (poll) while(!MCBSP_xrdy(DSK6713_AIC23_DATAHANDLE));//if ready to transmit

MCBSP_write(DSK6713_AIC23_DATAHANDLE,AIC_data.uint);//write/outp ut data } void output_left_sample(short out_data) //for output from left channel { AIC_data.uint=0; //clear data structure AIC_data.channel[LEFT]=out_data; //data from Left channel -- >data structure

if (poll) while(!MCBSP_xrdy(DSK6713_AIC23_DATAHANDLE));//if ready to transmit

MCBSP_write(DSK6713_AIC23_DATAHANDLE,AIC_data.uint);//output left channel } void output_right_sample(short out_data) //for output from right channel { AIC_data.uint=0; //clear data structure AIC_data.channel[RIGHT]=out_data; //data from Right channel -- >data structure

if (poll) while(!MCBSP_xrdy(DSK6713_AIC23_DATAHANDLE));//if ready to transmit

MCBSP_write(DSK6713_AIC23_DATAHANDLE,AIC_data.uint);//output right channel }

Uint32 input_sample() //for 32-bit input { short CHANNEL_data;

8 Manhattan College

if (poll) while(!MCBSP_rrdy(DSK6713_AIC23_DATAHANDLE));//if ready to receive AIC_data.uint=MCBSP_read(DSK6713_AIC23_DATAHANDLE);//read data

//Swapping left and right channels (see comments in output_sample()) CHANNEL_data=AIC_data.channel[RIGHT]; //swap left and right channel AIC_data.channel[RIGHT]=AIC_data.channel[LEFT]; AIC_data.channel[LEFT]=CHANNEL_data;

return(AIC_data.uint); } short input_left_sample() //input to left channel { if (poll) while(!MCBSP_rrdy(DSK6713_AIC23_DATAHANDLE));//if ready to receive AIC_data.uint=MCBSP_read(DSK6713_AIC23_DATAHANDLE);//read into left channel return(AIC_data.channel[LEFT]); //return left channel data } short input_right_sample() //input to right channel { if (poll) while(!MCBSP_rrdy(DSK6713_AIC23_DATAHANDLE));//if ready to receive AIC_data.uint=MCBSP_read(DSK6713_AIC23_DATAHANDLE);//read into right channel return(AIC_data.channel[RIGHT]); //return right channel data }

C6713dskinit.h Include file for C6713DSK.C

/*C6713dskinit.h Include file for C6713DSK.C */

#include "DSK6713.h" #include "DSK6713_aic23.h"

#define LEFT 1 //data structure for union of 32-bit data #define RIGHT 0 //into two 16-bit data union { Uint32 uint; short channel[2]; } AIC_data;

9 Manhattan College extern far void vectors(); //external function static Uint32 CODECEventId, poll;

// This is needed to modify the BSL's data channel McBSP configuration // See the changes below MCBSP_Config AIC23CfgData = { MCBSP_FMKS(SPCR, FREE, NO) | MCBSP_FMKS(SPCR, SOFT, NO) | MCBSP_FMKS(SPCR, FRST, YES) | MCBSP_FMKS(SPCR, GRST, YES) | MCBSP_FMKS(SPCR, XINTM, XRDY) | MCBSP_FMKS(SPCR, XSYNCERR, NO) | MCBSP_FMKS(SPCR, XRST, YES) | MCBSP_FMKS(SPCR, DLB, OFF) | MCBSP_FMKS(SPCR, RJUST, RZF) | MCBSP_FMKS(SPCR, CLKSTP, DISABLE) | MCBSP_FMKS(SPCR, DXENA, OFF) | MCBSP_FMKS(SPCR, RINTM, RRDY) | MCBSP_FMKS(SPCR, RSYNCERR, NO) | MCBSP_FMKS(SPCR, RRST, YES),

MCBSP_FMKS(RCR, RPHASE, SINGLE) | MCBSP_FMKS(RCR, RFRLEN2, DEFAULT) | MCBSP_FMKS(RCR, RWDLEN2, DEFAULT) | MCBSP_FMKS(RCR, RCOMPAND, MSB) | MCBSP_FMKS(RCR, RFIG, NO) | MCBSP_FMKS(RCR, RDATDLY, 0BIT) | MCBSP_FMKS(RCR, RFRLEN1, OF(0)) | // This changes to 1 FRAME MCBSP_FMKS(RCR, RWDLEN1, 32BIT) | // This changes to 32 bits per frame MCBSP_FMKS(RCR, RWDREVRS, DISABLE),

MCBSP_FMKS(XCR, XPHASE, SINGLE) | MCBSP_FMKS(XCR, XFRLEN2, DEFAULT) | MCBSP_FMKS(XCR, XWDLEN2, DEFAULT) | MCBSP_FMKS(XCR, XCOMPAND, MSB) | MCBSP_FMKS(XCR, XFIG, NO) | MCBSP_FMKS(XCR, XDATDLY, 0BIT) | MCBSP_FMKS(XCR, XFRLEN1, OF(0)) | // This changes to 1 FRAME MCBSP_FMKS(XCR, XWDLEN1, 32BIT) | // This changes to 32 bits per frame MCBSP_FMKS(XCR, XWDREVRS, DISABLE),

MCBSP_FMKS(SRGR, GSYNC, DEFAULT) | MCBSP_FMKS(SRGR, CLKSP, DEFAULT) | MCBSP_FMKS(SRGR, CLKSM, DEFAULT) | MCBSP_FMKS(SRGR, FSGM, DEFAULT) | MCBSP_FMKS(SRGR, FPER, DEFAULT) | MCBSP_FMKS(SRGR, FWID, DEFAULT) | MCBSP_FMKS(SRGR, CLKGDV, DEFAULT),

MCBSP_MCR_DEFAULT,

10 Manhattan College

MCBSP_RCER_DEFAULT, MCBSP_XCER_DEFAULT,

MCBSP_FMKS(PCR, XIOEN, SP) | MCBSP_FMKS(PCR, RIOEN, SP) | MCBSP_FMKS(PCR, FSXM, EXTERNAL) | MCBSP_FMKS(PCR, FSRM, EXTERNAL) | MCBSP_FMKS(PCR, CLKXM, INPUT) | MCBSP_FMKS(PCR, CLKRM, INPUT) | MCBSP_FMKS(PCR, CLKSSTAT, DEFAULT) | MCBSP_FMKS(PCR, DXSTAT, DEFAULT) | MCBSP_FMKS(PCR, FSXP, ACTIVEHIGH) | MCBSP_FMKS(PCR, FSRP, ACTIVEHIGH) | MCBSP_FMKS(PCR, CLKXP, FALLING) | MCBSP_FMKS(PCR, CLKRP, RISING) };

DSK6713_AIC23_Config config = { \ 0x0017, /* Set-Up Reg 0 Left line input channel volume control */ \ /* LRS 0 simultaneous left/right volume: disabled */\ /* LIM 0 left line input mute: disabled */ \ /* XX 00 reserved */ \ /* LIV 10111 left line input volume: 0 dB */ \

\ 0x0017, /* Set-Up Reg 1 Right line input channel volume control */ \ /* RLS 0 simultaneous right/left volume: disabled */\ /* RIM 0 right line input mute: disabled */ \ /* XX 00 reserved */ \ /* RIV 10111 right line input volume: 0 dB */ \

\ 0x01f9, /* Set-Up Reg 2 Left channel headphone volume control */ \ /* LRS 1 simultaneous left/right volume: enabled */ \ /* LZC 1 left channel zero-cross detect: enabled */ \ /* LHV 1111001 left headphone volume: 0 dB */ \

\ 0x01f9, /* Set-Up Reg 3 Right channel headphone volume control */ \

11 Manhattan College

/* RLS 1 simultaneous right/left volume: enabled */ \ /* RZC 1 right channel zero-cross detect: enabled */\ /* RHV 1111001 right headphone volume: 0 dB */ \

\ 0x0015, /* Set-Up Reg 4 Analog audio path control */ \ /* X 0 reserved */ \ /* STA 00 sidetone attenuation: -6 dB */ \ /* STE 0 sidetone: disabled */ \ /* DAC 1 DAC: selected */ \ /* BYP 0 bypass: off */ \ /* INSEL 0 input select for ADC: line */ \ /* MICM 0 microphone mute: disabled */ \ /* MICB 1 microphone boost: enabled */ \

\ 0x0000, /* Set-Up Reg 5 Digital audio path control */ \ /* XXXXX 00000 reserved */ \ /* DACM 0 DAC soft mute: disabled */ \ /* DEEMP 00 deemphasis control: disabled */ \ /* ADCHP 0 ADC high-pass filter: disabled */ \

\ 0x0000, /* Set-Up Reg 6 Power down control */ \ /* X 0 reserved */ \ /* OFF 0 device power: on (i.e. not off) */ \ /* CLK 0 clock: on */ \ /* OSC 0 oscillator: on */ \ /* OUT 0 outputs: on */ \ /* DAC 0 DAC: on */ \

12 Manhattan College

/* ADC 0 ADC: on */ \ /* MIC 0 microphone: on */ \ /* LINE 0 line input: on */ \

\ 0x0043, /* Set-Up Reg 7 Digital audio interface format */ \ /* XX 00 reserved */ \ /* MS 1 master/slave mode: master */ \ /* LRSWAP 0 DAC left/right swap: disabled */ \ /* LRP 0 DAC lrp: MSB on 1st BCLK */ \ /* IWL 00 input bit length: 16 bit */ \ /* FOR 11 data format: DSP format */ \

\ 0x0081, /* Set-Up Reg 8 Sample rate control */ \ /* X 0 reserved */ \ /* CLKOUT 1 clock output divider: 2 (MCLK/2) */ \ /* CLKIN 0 clock input divider: 2 (MCLK/2) */ \ /* SR,BOSR 00000 sampling rate: ADC 48 kHz DAC 48 kHz */ \ /* USB/N 1 clock mode select (USB/normal): USB */ \

\ 0x0001 /* Set-Up Reg 9 Digital interface activation */ \ /* XX..X 00000000 reserved */ \ /* ACT 1 active */ \ };

DSK6713_AIC23_CodecHandle hAIC23_handle; void c6713_dsk_init(); void comm_poll(); void comm_intr(); void output_sample(int); void output_left_sample(short); void output_right_sample(short); Uint32 input_sample();

13 Manhattan College short input_left_sample(); short input_right_sample();

Vectors_intr.asm Vector file for interrupt INT11

*Vectors_intr.asm Vector file for interrupt INT11 .global _vectors ;global symbols .global _c_int00 .global _vector1 .global _vector2 .global _vector3 .global _vector4 .global _vector5 .global _vector6 .global _vector7 .global _vector8 .global _vector9 .global _vector10 .global _c_int11 ;for INT11 .global _vector12 .global _vector13 .global _vector14 .global _vector15

.ref _c_int00 ;entry address

VEC_ENTRY .macro addr ;macro for ISR STW B0,*--B15 MVKL addr,B0 MVKH addr,B0 B B0 LDW *B15++,B0 NOP 2 NOP NOP .endm

_vec_dummy: B B3 NOP 5

.sect ".vectors" ;aligned IST section .align 1024 _vectors: _vector0: VEC_ENTRY _c_int00 ;RESET _vector1: VEC_ENTRY _vec_dummy ;NMI _vector2: VEC_ENTRY _vec_dummy ;RSVD _vector3: VEC_ENTRY _vec_dummy _vector4: VEC_ENTRY _vec_dummy _vector5: VEC_ENTRY _vec_dummy _vector6: VEC_ENTRY _vec_dummy _vector7: VEC_ENTRY _vec_dummy _vector8: VEC_ENTRY _vec_dummy

14 Manhattan College

_vector9: VEC_ENTRY _vec_dummy _vector10: VEC_ENTRY _vec_dummy _vector11: VEC_ENTRY _c_int11 ;ISR address _vector12: VEC_ENTRY _vec_dummy _vector13: VEC_ENTRY _vec_dummy _vector14: VEC_ENTRY _vec_dummy _vector15: VEC_ENTRY _vec_dummy

C6713dsk.cmd Linker command file

/*C6713dsk.cmd Linker command file*/

MEMORY { IVECS: org=0h, len=0x220 IRAM: org=0x00000220, len=0x0002FDE0 /*internal memory*/ SDRAM: org=0x80000000, len=0x01000000 /*external memory*/ FLASH: org=0x90000000, len=0x00020000 /*flash memory*/ }

SECTIONS { .EXT_RAM :> SDRAM .vectors :> IVECS /*in vector file*/ .text :> IRAM /*Created by C Compiler*/ .bss :> IRAM .cinit :> IRAM .stack :> IRAM .sysmem :> IRAM .const :> IRAM .switch :> IRAM .far :> IRAM .cio :> IRAM .csldata :> IRAM }

15