DSP C5000 Chapter 21 Frequency Modulation GMSK Modulation Copyright © 2003 Texas Instruments. All rights reserved. Learning Objectives ESIEE, Slide 2 Overview of Digital Modulation Understanding GMSK Modulation Learning how to Implement a GMSK Modulator on a C54 Copyright © 2003 Texas Instruments. All rights reserved. Digital Modulations Baseband and bandpass signalling are used to transmit data on physical channels such as telephone cables or radiofrequency channels. The source of data (bits or symbol) may be a computer file or a digitized waveform (speech, video…) The transmitted signal carries information about the data and its characteristic changes at the same rate as the data. When the signal carrying the data information Extends from 0 Hz upwards, the term baseband signalling is used. Has its power centered on a central frequency fc, the term bandpass signalling or modulation is used. ESIEE, Slide 3 Copyright © 2003 Texas Instruments. All rights reserved. Digital Modulation Modulation is used because: ESIEE, Slide 4 The channel does not include the 0 Hz frequency and baseband signalling is impossible The bandwidth of the channel is split between several channels for frequency multiplexing For wireless radio-communications, the size of the antenna decreases when the transmitted frequency increases. Copyright © 2003 Texas Instruments. All rights reserved. Carrier Frequency In simple modulation schemes, a single frequency signal, the carrier, is modified at the rate of the data. The carrier is commonly written as: A cos 2 f c t ESIEE, Slide 5 fc= Carrier frequency A = Carrier Amplitude = Carrier phase The 3 main parameters of the carrier: amplitude, phase and frequency can be modified to carry the information leading to: amplitude, phase and frequency modulation. Copyright © 2003 Texas Instruments. All rights reserved. Digital Modulation CPM: Continuous Phase Modulation QAM: Quadrature Amplitude Modulation Example: QPSK, OQPSK, 16QAM Characteristic: High spectral efficiency Multicarrier Modulation ESIEE, Slide 6 Frequency or phase modulation Example: MSK, GMSK Characteristic: constant envelope modulation Example: OFDM, DMT Characteristic: Muti-path delay spread tolerance, effectivness against channel distortion Copyright © 2003 Texas Instruments. All rights reserved. What is the Complex Envelope z(t) of a Modulated Signal x(t) ? x ( t ) z ( t ) e j 2 f c t z I ( t )cos 2 f c t z Q ( t ) sin 2 f c t . fc= Carrier frequency z ( t ) x ( t ) jx H ( t ) e j 2 fct z I ( t ) jz Q ( t ) A ( t ) e j ( t ) z(t) = Complex envelope of x(t) zI(t), zQ(t) are the baseband components xH(t) = Hilbert transform of x(t) = x(t) with a phase shift of /2 S x ( f ) 1 S z ( f f c ) S z ( f f c ) . 2 Sx(f) = Power spectral density of x(t) ESIEE, Slide 7 Copyright © 2003 Texas Instruments. All rights reserved. Complex Envelope z of a Modulated Signal x Frequency Domain 2 X (f) 1 1 f 0 2 X a (f) 2 1 f 0 2 Z (f) 2 1 f 0 ESIEE, Slide 8 Copyright © 2003 Texas Instruments. All rights reserved. GMSK Modulation Gaussian Minimum Shift Keying. Used in GSM and DECT standards. Relevant to mobile communications because of constant envelope modulation: ESIEE, Slide 9 Quite insensitive to non-linearities of power amplifier Robust to fading effects But moderate spectral efficiency. Copyright © 2003 Texas Instruments. All rights reserved. What is GMSK Modulation? Continuous phase digital frequency modulation Modulation index h=1/2 Gaussian Frequency Shaping Filter GMSK = MSK + Gaussian filter Characterized by the value of BT ESIEE, Slide 10 T = bit duration B = 3dB Bandwidth of the shaping filter BT = 0.3 for GSM BT = 0.5 for DECT Copyright © 2003 Texas Instruments. All rights reserved. GMSK Modulation, Expression for the Modulated Signal x(t) x ( t ) cos 2 f c t ( t ) w ith: t ( t ) 2 h a k s ( kT ) d k ak = Binary data = +/- 1 h = Modulation index = 0.5 Normalization s(t) = Gaussian frequency shaping filter s(t)= Elementary frequency pulse s ( ) d ESIEE, Slide 11 1 2 Copyright © 2003 Texas Instruments. All rights reserved. GMSK Elementary Phase Pulse t q (t ) s ( ) d . E lem entary phase pulse = ( t ) t ( t ) 2 hq ( t ) 2 h s ( ) d . For t nT , ( n 1)T n ( t ) 2 h n a k q ( t kT ) k x ( t ) cos 2 f c t ( t ) cos 2 f c t ESIEE, Slide 12 a k ( t kT ) k a ( t kT ) k . k n Copyright © 2003 Texas Instruments. All rights reserved. Architecture of a GMSK Modulator G M S K m o d u lato r u sin g a V C O a k t kT a s t kT k k k C o d er r (t ) x(t ) VCO h(t ) B its ak h s (t ) r (t ) * h (t ) R ectan g u lar filter G au ssian filter G M S K m o d u lato r w ith o u t V C O co s 2 f c t co s() 2h a t kT k k t C od er s(t ) B its a k s( t ) r ( t ) * h ( t ) ESIEE, Slide 13 (t) sin 2 f c t + x (t) sin () Copyright © 2003 Texas Instruments. All rights reserved. Equation for the Gaussian Filter h(t) h (t ) 2 2 B 2 2 B exp t ln(2) ln(2) 2 ln(2) 2 H ( f ) exp f 2 2B The duration MTb of the gaussian pulse is truncated to a value inversely proportional to B. BT = 0.5, MTb = 2Tb BT = 0.3, MTb = 3 or 4Tb ESIEE, Slide 14 Copyright © 2003 Texas Instruments. All rights reserved. Frequency and Phase Elementary Pulses Tbg(t ) Elementary frequency pulse BTb 0.5 BTb 05 , BTb 03 , 0.4 0.3 (t ) Elementary phase pulse 1.6 /2 BT b 1.4 1.2 BT b 1 BT b 0 .5 0 .3 0.8 0.6 0.2 0.4 0.1 0 0.2 0 -2 -1 0 1 2 t in number of bit periods Tb -2 -1 0 1 2 t in number of bit period Tb The elementary frequency pulse is the convolution of a square pulse r(t) with a gaussian pulse h(t). Its duration is (M+1)Tb. ESIEE, Slide 15 Copyright © 2003 Texas Instruments. All rights reserved. GMSK Signals 1 Binary sequence t 0 -1 0 5 10 15 20 1 t GMSK modulated Signal 0 -1 (t ) 0 5 10 15 20 5 t 0 in rd -5 z I ( t ) cos ( t ) 1 0 5 10 15 20 t 0 -1 0 5 10 15 20 1 z Q ( t ) sin ( t ) 0 -1 ESIEE, Slide 16 t 0 5 10 15 20 Copyright © 2003 Texas Instruments. All rights reserved. Power Spectral Density of GMSK Signals P o w er sp ectral d en sity o f th e co m p lex en v elo p e o f G M S K , B T = 0 .3 , fe= 8 , T = 1 . L o garith m ic scale 20 0 -2 0 -4 0 -6 0 -8 0 -1 0 0 -1 2 0 -1 4 0 0 ESIEE, Slide 17 0 .5 1 1 .5 2 2 .5 3 F req u en cy n o rm aliz ed b y 1 /T 3 .5 4 Copyright © 2003 Texas Instruments. All rights reserved. Implementing a GMSK Modulator on a DSP Quadrature modulation can be used: The DSP calculates the phase and the 2 baseband components zI and zQ and sends them to the DAC. Or a modulated loop can be used. In this case, the DSP generates the instantaneous frequency finst signal that is sent to the DAC. f in st h a k s ( kT ). k ESIEE, Slide 18 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Instantaneous Frequency finst is obtained by a simple filtering of the bit sequence ak by a FIR filter of impulse response s(n). Open Matlab routine pul_phas.m to calculate s(n). Explanation of parameters are given in following slides. ESIEE, Slide 19 Copyright © 2003 Texas Instruments. All rights reserved. Expression for the Baseband Components The baseband components zI and zQ are modulated in amplitude by the 2 quadrature carriers. x ( t ) cos 2 f c t ( t ) cos ( t ) cos 2 f c t sin ( t ) sin 2 f c t x ( t ) z I ( t ) cos 2 f c t z Q ( t ) sin 2 f c t ESIEE, Slide 20 Copyright © 2003 Texas Instruments. All rights reserved. Baseband Components and Carriers Baseband components z I ( t ) cos ( t ) z Q ( t ) sin ( t ) The carriers are generally RF analog signals generated by analog oscillators However, we will show how they could be generated digitally if the value of fc were not too high. C arrierI cos 2 f c t C arrierQ sin 2 f c t ESIEE, Slide 21 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Baseband Components on a DSP Calculate the phase at time mTS Ts the sampling frequency. Read the value of cos() and sin() from a table. For t nT , ( n 1)T n (t ) a k ( t kT ). k n ( m TS ) a k ( m T S kT ). k ESIEE, Slide 22 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Elementary Pulse Phase with Matlab The elementary pulse phase (mTS) is calculated with Matlab and stored in memory. The duration LT of the evolutive part of (mTS) depends on the value of BT. is called phi in the matlab routine. t ( t ) 2 h s ( ) d (t ) 0 t 0 ( t ) h t L T ESIEE, Slide 23 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Elementary Pulse Phase with Matlab 1/2 Beginning of the matlab routine function [phi,s]= pul_phas(T _over_T s,L ,B T ,T ) T s= T / T _over_T s ; % calculates the num ber of sam ples in phi in the interval 0 - L T N phi= ceil(T _over_T s*L ); % calculates the num ber of sam ples in T N ts= ceil(T _over_T s); Open Matlab routine pul_phas.m phi= zeros(1,N phi); s= zeros(1,N phi); sigm a= sqrt(log(2))/2/pi/(B T /T ) ESIEE, Slide 24 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Elementary Pulse Phase with Matlab 2/2 End of the matlab routine t= [-L * T /2 :T s:L * T /2 ]; t= t(1 :N ph i); ta= t+ T /2 ; tb = t-T /2 ; Q ta= 0.5*(on es(1,N ph i)+ erf(ta/sig m a/sqrt(2))); Q tb= 0.5*(on es(1,N ph i)+ erf(tb /sig m a/sqrt(2))); exp ta= exp (-0 .5 *((ta/sigm a).^2 ))/sq rt(2* p i)* sig m a; exp tb = exp (-0 .5 *((tb /sigm a).^2 ))/sq rt(2* p i)* sig m a; p h i= p i/T /2 *(ta.*Q ta+ ex p ta -tb .* Q tb -ex p tb ); s= 1 /2 /T *(Q ta -Q tb); ESIEE, Slide 25 Copyright © 2003 Texas Instruments. All rights reserved. Using the Matlab Routine Start Matlab Use: call the routine using to calculate the phase pulse phi ( ) and the pulse s: [phi,s]=pul_phas(T_over_Ts,L,BT,T) Plot the phase phi and the shaping pulse s ESIEE, Slide 26 T_over_Ts=8 L=4 T=1 BT=0.3 plot(phi) plot(s) Copyright © 2003 Texas Instruments. All rights reserved. Results of Matlab Routine ESIEE, Slide 27 Copyright © 2003 Texas Instruments. All rights reserved. Results for phi For L=4 and T_over_Ts=8, we obtain 32 samples for phi. Matlab gives the following values for phi: Phi= [0.0001, 0.0062, 0.0127, 0.1884, 0.2740, 0.9299, 1.0672, 1.4945, 1.5262, 1.5696, 1.5703, After this evolutive part of phi, phi stays equal to /2 (1.57). To calculate , the evolutive part and the constant part of the elementary phase pulse phi are treated separately. ESIEE, Slide 28 0.0002, 0.0005, 0.0246, 0.0446, 0.3798, 0.5036, 1.1910, 1.2968, 1.5462, 1.5581, 1.5706] 0.0012, 0.0763, 0.6409, 1.3824, 1.5646, 0.0028, 0.1231, 0.7854, 1.4476, 1.5680, Copyright © 2003 Texas Instruments. All rights reserved. Calculation of Separation of evolutive and constant parts of phi. F o r t n T , ( n 1)T nL n (t ) a k ( t kT ) k k n a k ( t kT ) a k ( t kT ) w ith : k n L 1 (t ) 0 t 0 ( t ) h h t LT 2 (t ) 2 ESIEE, Slide 29 n L k n ak k n L 1 n a k ( t kT ) p h im em ( n ) a k ( t kT ) k n L 1 Copyright © 2003 Texas Instruments. All rights reserved. Memory Part and Evolutive Part of For t nT , ( n 1)T phim em ( n ) phim em ( n 1) a ( n L ) . 2 n ( t ) phim em ( n ) a k ( t kT ) k n L 1 t m TS n ( m T S ) phim em ( n ) a k ( m T S kT ) k n L 1 ESIEE, Slide 30 Copyright © 2003 Texas Instruments. All rights reserved. Recursive Calculation of Names of variables Phase = phi = array of evolutive part of , Ns = number of samples per bit = T/Ts an = binary sequence (+/- 1) 2 calculation steps: ESIEE, Slide 31 Nphi samples = LT/Ts Calculate Calculate zI=cos() and zQ=sin() by table reading Copyright © 2003 Texas Instruments. All rights reserved. Calculation of : Initialization Initialization step: L first bit periods, phimem = 0 At bit L+1, phimem is set to a1 /2. Principle of the initialization processing: FOR i=1 to i=L for j=(i-1)Ns+1 to j=(i-1)Ns+Nphi ESIEE, Slide 32 phase((i-1)Ns+j)= phase((i-1)Ns+j)+phi(j)an(i) Endfor endFOR phimem=an(1) /2 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of : After Initialization FOR i=L+1 to last_bit For j=(i-1)Ns+1 to j=(i-1)Ns+Nphi endFor For j=(i-1)Ns+1 to j=i Ns ESIEE, Slide 33 phase((i-1)Ns+j)= phase((i-1)Ns+j)+phi(j)an(i) phase((i-1)Ns+j)= phase((i-1)Ns+j)+phimem xi=cos(phase(i-1)Ns+j) xq=sin(phase((i-1)Ns+j) endFor phimem=phimem+pi/2 an(i+1-L) endFOR Copyright © 2003 Texas Instruments. All rights reserved. Coding and Wrapping the Phase Table The phase value in [-,[ is represented by the 16-bit number Iphase Minimum phase = -, Iphase = -215. Maximum phase = (1-215), Iphase = 215-1. 15 Iphase ESIEE, Slide 34 2 phase Copyright © 2003 Texas Instruments. All rights reserved. Index for the table in Phase Calculation Phase increment between 2 table values: 2 / Ncos and on Iphase 216/Ncos For Iphase, the index of the table is: ESIEE, Slide 35 i= Ncos Iphase 2-16 Here Ncos 2-16 = 2-9, So the index in the table is given by shifting Iphase 9 bits to the right. Copyright © 2003 Texas Instruments. All rights reserved. Coding of phi The quantized values of phi can be obtained with Matlab: phi ESIEE, Slide 36 phi= round(phi*2^15/pi); phi is defined and initialized in the file phi03.asm as: .ref phi .sect "phi" .word 1,2,5,13,29,65,133,256 .word 465,795,1284,1965,2858,3961,5252,6685 .word 8192,9699,11132,12423,13526,14419,15100,15589 .word 15919,16128,16251,16319,16355,16371,16379,16382 Copyright © 2003 Texas Instruments. All rights reserved. Calculation of sin() and cos() by Table Lookup We use a table of cosine values Length of the table Ncos=128, circular buffer Contents of the table: cosine of angles i uniformly distributed between - and . i ESIEE, Slide 37 i N N cos N cos i , 1 2 2 deb_cos = first address of the table mid_cos = address of the table middle cos(i ) is at address mid_cos + i Copyright © 2003 Texas Instruments. All rights reserved. Calculation of sin() and cos() by Table Lookup Conversion of the phase modulo 2: Wrapping phase in [-,[ Done by a macro: testa02pi * Macro to wrap the phase between testa02pi .macro SUB #8000h,A,B BC suite1?, BGEQ SUB #8000h,A SUB #8000h,A B suite? suite1? ADD #8000h,A,B BC suite?,BLT ADD #8000h,A ADD #8000h,A suite? .endm ESIEE, Slide 38 - et , phase is in ACCU A ; ; ; ; sub -2^(15) test if phase is in [0,2pi[ sub -2^(15) SUB -2^(15) ; add -2^(15) ; add -2^(15) ; add -2^(15) ; end of test Copyright © 2003 Texas Instruments. All rights reserved. Generating the Sine Values from a Table of Cosine Values To generate sin() from the table of cosine values, we use: cos(/2 - ) or cos(-/2 + ) or cos(3/2+ ) If i is the index of the cosine, for the sine we use: ESIEE, Slide 39 i-Ncos/4 i+3Ncos /4 if i>= -Ncos/4 if i < Ncos/4. Copyright © 2003 Texas Instruments. All rights reserved. Implementation on a C54x, Test Sequence We can test the GMSK modulation on a given periodical binary sequence an: an=[ 0 1 1 0 0 1 0 1 0 0] These bits are stored in a circular buffer: Size NB = 10 Declaration of a section bits aligned on an address which is a multiple of 16 bits. AR5 d eb _b it NB an ESIEE, Slide 40 Copyright © 2003 Texas Instruments. All rights reserved. Testing the Generation of on the C54x, Results Buffer We calculate and store it in a buffer pointed by AR1. The size of the result buffer is 1000 words. resu AR1 1000 B u ffer for th e last 1000 resu lt valu es of ESIEE, Slide 41 Copyright © 2003 Texas Instruments. All rights reserved. Testing the Generation of on the C54x Buffers d eb _p h ase AR3 phi AR4 Nphi phi C ircu lar B u ffer for p h i (evolu tive p art) A llocated at an ad d ress m u ltip le of 64 (N p h i = 32) ESIEE, Slide 42 Nphi p h ase C ircu lar B u ffer for th e variab le p h ase A llocated at an ad d ress m u ltip le of 64 (N p h i = 32) Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Definitions Nphi Nphim L Ncos Nsur2 Nsur4 NB NS ESIEE, Slide 43 .mmregs .global .global .global .global .set .set .set .set .set .set .set .set .bss debut,boucle deb_cos, phi deb_phase resu 32 -32 4 128 64 32 10 8 resu,1000 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Macro for phase wrapping * Definition of macro of phase wrapping testa02pi testa02pi .macro SUB #8000h,A,B ;sub -2^(15) BC suite1?, BGEQ ;test if phase in [0,2pi[ SUB #8000h,A ;sub -2^(15) SUB #8000h,A ;sub -2^(15) B suite? suite1? ADD #8000h,A,B ;add -2^(15) BC suite?,BLT ADD #8000h,A ;add -2^(15) ADD #8000h,A ;add -2^(15) suite? ;end test wrapping [0,2pi[ .endm ESIEE, Slide 44 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Initialization of Registers and Buffers 1/2 .text * Initialization of BK, DP, ACCUs, and ARi debut: LD #0, DP LD #0, A LD #0, B STM #deb_bit,AR5 STM #deb_cos,AR2 STM #deb_phase ,AR3 STM #phi,AR4 STM #resu,AR1 STM +1,AR0 STM #Nphi, BK STM #(NS-1),AR7 RSBX OVM SSBX SXM ESIEE, Slide 45 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Initialization of Registers and Buffers 2/2 * Initialization of the phase buffer RPT #(Nphi-1) STL A,*AR3+% *initialization of phimem LD *AR5,T MPY #04000h,A ; -2^(14) an(1)(pi/2 an(1)) STL A,*(phimem) ESIEE, Slide 46 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Calculation for the first L bits * processing for the first L bits STM #(L-1),AR6 Ldeb STM #Nphi-1,BRC RPTB fin-1 LD *AR3,A MAC *AR4+0%,*AR5,A testa02pi STL A,*AR3+% NOP fin NOP STM #(NS-1), AR7 Nsbouc LD *AR3,A STL A,*AR1+ ST #0,*AR3+% BANZ nsbouc,*AR7STM MAR STM BANZ ESIEE, Slide 47 ; from k=0 to k=Nphi ; accu=phase(k) ; A=phase(k)+an(i) phi(k) ; A->phase(k) ; output of NS values ; and reset at 0 of NS words #NB, BK *AR5+% #Nphi,BK Ldeb, *AR6- Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Calculation of the Following Bits 1/2 * begin of the infinite loop boucle STM #Nphi-1,BRC RPTB fin2-1 ; for k=0 to Nphi LD *AR3,A ; accu=phase(k) MAC *AR4+0%,*AR5,A ; A=phase(k)+an(i) phi(k) testa02pi STL A,*AR3+% ; A->phase(k) fin2 * adding phimem to the NS first points of the array * then taking them out and reset to 0 in phase STM #NS-1,AR7 nsbouc2 LD *(phimem),B ADD *AR3,B,A ; B=phimem+phase(k) testa02pi STL A,*AR1+ ST #0,*AR3+% ; 0->phase(k) BANZ nsbouc2,*AR7- ; .... ESIEE, Slide 48 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of Calculation of the Following Bits 2/2 fin3 * actualization of phimem LD *(phimem),A STM #NB, BK MAR *+AR5(#unmL)% LD *AR5,T MAC #04000h,A ; -2^(14) an(1)(pi/2 an(1)) testa02pi STL A,*(phimem) MAR *+AR5(#L)% STM #Nphi,BK B boucle .end ESIEE, Slide 49 Copyright © 2003 Texas Instruments. All rights reserved. Illustration of the Phase Result Wrapped Between - and ESIEE, Slide 50 Plot under CCS the buffer of phase results Copyright © 2003 Texas Instruments. All rights reserved. Generation of the Baseband Components zI=cos() and zQ=sin() We calculate zI and zQ and we do not need to save the phase any more. We output ZI and Zq, in this example on DXR0 and DXR1. We need the table of constants for the values of cosine. ESIEE, Slide 51 This table is defined in the file tabcos.asm The cosine values are given in format Q14. Copyright © 2003 Texas Instruments. All rights reserved. File tabcos.asm deb_cos mid_cos ESIEE, Slide 52 .def deb_cos,mid_cos .sect "tab_cos" .word -16384,-16364,-16305,-16207,-16069,-15893,-15679,-15426 .word -15137,-14811,-14449,-14053,-13623,-13160,-12665,-12140 .word -11585,-11003,-10394,-9760,-9102,-8423,-7723,-7005 .word -6270,-5520,-4756,-3981,-3196,-2404,-1606,-804 .word 0,804,1606,2404,3196,3981,4756,5520 .word 6270,7005,7723,8423,9102,9760,10394,11003 .word 11585,12140,12665,13160,13623,14053,14449,14811 .word 15137,15426,15679,15893,16069,16207,16305,16364 .word 16384,16364,16305,16207,16069,15893,15679,15426 .word 15137,14811,14449,14053,13623,13160,12665,12140 .word 11585,11003,10394,9760,9102,8423,7723,7005 .word 6270,5520,4756,3981,3196,2404,1606,804 .word 0,-804,-1606,-2404,-3196,-3981,-4756,-5520 .word -6270,-7005,-7723,-8423,-9102,-9760,-10394,-11003 .word -11585,-12140,-12665,-13160,-13623,-14053,-14449,-14811 .word -15137,-15426,-15679,-15893,-16069,-16207,-16305,-16364 .set deb_cos+64 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Calculation of zI and zQ The listing for definitions and initializations is the same as before. Processing of the L first bits, Processing of the other bits ESIEE, Slide 53 (infinite loop) Copyright © 2003 Texas Instruments. All rights reserved. Processing of the First L Bits 1/2 Processing of the L first bits STM #(L-1),AR6 Ldeb STM #Nphi-1,BRC RPTB fin-1 ; from k=0 to Nphi LD *AR3,A ; accu=phase(k) MAC *AR4+0%,*AR5,A ; A=phase(k)+an(i) phi(k) testa02pi STL A,*AR3+% ; A->phase(k) fin NOP STM #(NS-1), AR7 Nsbouc LD *AR3,A ; output of NS values SFTA A,-9,A ADD #mid_cos,A,B STLM B,AR1 NOP NOP LD *AR1,B STL B,DXR0 * ESIEE, Slide 54 Copyright © 2003 Texas Instruments. All rights reserved. Processing of the First L Bits 2/2 * Calculation of the sine ADD #Nsur4,A,B BC sui,BGT ADD #(Nsur2),B B sui1 sui SUB #Nsur2,B sui1 ADD #mid_cos,B ESIEE, Slide 55 STLM NOP NOP LD STL ST BANZ B,AR1 STM MAR STM #NB, BK *AR5+% #Nphi,BK *AR1,A A,DXR1 #0,*AR3+% nsbouc,*AR7- Copyright © 2003 Texas Instruments. All rights reserved. Processing of the Following bits 1 of 2 * begin the infinite loop boucle STM #Nphi-1,BRC RPTB fin2-1 ; for k=0 to Nphi LD *AR3,A ; accu=phase(k) MAC *AR4+0%,*AR5,A ; A=phase(k)+an(i) phi(k) testa02pi STL A,*AR3+% ; A->phase(k) fin2 *phimem is added to the NS first points of the array * then they are output and words are reset to 0 in buffer phase STM #NS-1,AR7 nsbouc2 LD *(phimem),B ADD *AR3,B,A ; A=phimem+phase(k) testa02pi SFTA A,-9,A ADD #mid_cos,A,B STLM B,AR1 NOP NOP LD *AR1,B STL B,DXR0 ESIEE, Slide 56 Copyright © 2003 Texas Instruments. All rights reserved. Processing of the Following Bits 2 of 2 * Calculation of the sine NOP ADD #Nsur4,A,B NOP NOP BC suii,BGT ADD #(Nsur2),B B suii1 suii SUB #(Nsur2) ,B suii1 ADD #mid_cos,B STLM B,AR1 NOP NOP LD *AR1,A STL A,DXR1 ST #0,*AR3+% ; 0->phase(k) BANZ nsbouc2,*AR7fin3 * actualization of phimem LD *(phimem),A STM #NB, BK MAR *+AR5(#unmL)% LD *AR5,T MAC #04000h,A ; -2^(14) an(1)(pi/2 an(1)) testa02pi STL A,*(phimem) MAR *+AR5(#L)% STM #Nphi,BK B boucle .end ESIEE, Slide 57 Copyright © 2003 Texas Instruments. All rights reserved. Results Observed in CCS ESIEE, Slide 58 Copyright © 2003 Texas Instruments. All rights reserved. Generation of 2 Quadrature Carriers Generation of: ESIEE, Slide 59 cos(2fct) and sin (2fct) fc is the frequency of the carrier In this example we choose fc=1/T Sampling frequency = 1/Ts = fS In RF applications, the carriers are not generated by the DSP. It is only possible to use the DSP for low values of fc. The angle (t)= 2fct is calculated then the value of cos() is read from a table. Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Angle of the Carriers Recursive calculation of the angle : ( nTS ) 2 f c nTS ( n 1)TS 2 f cTS ( n 1)Ts ESIEE, Slide 60 The precision of the generated frequency depends on the precision of . The phase increment corresponds to an increment I to the integer that represents . I=216fcTS rounded to the closest integer. Copyright © 2003 Texas Instruments. All rights reserved. Calculation of the Angle of the Carriers If the number of samples per period of the carrier is a power of 2, 2k: I=216fcTS=2(16-k) is exact Then the precision of the generated frequency depends only on the precision of the sampling frequency. Otherwise, there is an error dfc in fc: ESIEE, Slide 61 |dfc|<2-17fS. Error in the amplitudes of the carriers due to finite precision of the table reading. (possible interpolation). Copyright © 2003 Texas Instruments. All rights reserved. Implementation on a C54x We use: fs/fc=8=Ns. The cosine table has 128 Values in Q14. d eb _cos AR1 128 C osin e valu es C ircu lar b u ffer,T ab le of cosin e ESIEE, Slide 62 Copyright © 2003 Texas Instruments. All rights reserved. Implementation on a C54x ESIEE, Slide 63 Here k=3 (8 samples per period) and the increment I=216fcTS=2(16-k) =213 Simple case of fS/fc as an integer value, the table is read with an offset from the pointer = 16 = 27/23 to generate a cosine with 8 samples per period. We can work directly on the index i and not on I. Copyright © 2003 Texas Instruments. All rights reserved. Generation of the Cosine and Sine Carriers For the cosine: For the sine: ESIEE, Slide 64 The circular buffer containing the cosine values (length N) is accessed with AR1. Incremented by the content of AR0=16. AR1 initialized with deb_cos. Same circular buffer accessed by AR2. AR2 initialized with deb_cos + Ncos/4. Decremented by AR0=16. Outputs (cos and sin) are sent to DXR0 and DXR1. Copyright © 2003 Texas Instruments. All rights reserved. Generation of quadrature 2 Carriers File porteuse.asm A file associated with DXR0 and DXR1 is used to save visual results obtained with the CCS simulator. Here cosine table goes from: ESIEE, Slide 65 0 to 2 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Generation of 2 Carriers 1 of 2 .mmregs .global debut,boucle Ncos .set 128 Nsur2 .set 64 Nsur4 .set 32 Inc .set 16 * Definition and initialization of Table of cosine .sect "tab_cos" deb_cos .word 16384,16364,16305,16207,16069,15893,15679,15426 .word 15137,14811,14449,14053,13623,13160,12665,12140 .word 11585,11003,10394,9760,9102,8423,7723,7005 .word 6270,5520,4756,3981,3196,2404,1606,804 .word 0,-804,-1606,-2404,-3196,-3981,-4756,-5520 .word -6270,-7005,-7723,-8423,-9102,-9760,-10394,-11003 .word -11585,-12140,-12665,-13160,-13623,-14053,-14449,-14811 .word -15137,-15426,-15679,-15893,-16069,-16207,-16305,-16364 .word -16384,-16364,-16305,-16207,-16069,-15893,-15679,-15426 .word -15137,-14811,-14449,-14053,-13623,-13160,-12665,-12140 .word -11585,-11003,-10394,-9760,-9102,-8423,-7723,-7005 .word -6270,-5520,-4756,-3981,-3196,-2404,-1606,-804 .word 0,804,1606,2404,3196,3981,4756,5520 .word 6270,7005,7723,8423,9102,9760,10394,11003 .word 11585,12140,12665,13160,13623,14053,14449,14811 .word 15137,15426,15679,15893,16069,16207,16305,16364 ESIEE, Slide 66 Copyright © 2003 Texas Instruments. All rights reserved. Listing for the Generation of 2 Carriers 2 of 2 .text * Initializations of DP, and of the phase Ialpha at 0 * The phase Ialpha is in ACCU A, and the index of table in B * attention we work in the part of ACCUs * Initialize AR1 at mid_cos and AR0 at Nsur4 debut: LD #0, DP LD #0, A STM #Ncos,BK STM #deb_cos,AR1 STM #(deb_cos+Nsur4),AR2 STM #Inc, AR0 * endless loop boucle: LD *AR1+0%,A STL A, DXR0 LD *AR2-0%,B STL B,DXR0 * Return to the beginning of the endless loop B boucle ESIEE, Slide 67 Copyright © 2003 Texas Instruments. All rights reserved. Results Obtained with CCS ESIEE, Slide 68 Copyright © 2003 Texas Instruments. All rights reserved. Tutorial The listing files for the precedent examples can be found in the directory “tutorial”: ESIEE, Slide 69 Tutorial > Dsk5416 > Chapter 21 > Labs_modulation Copyright © 2003 Texas Instruments. All rights reserved. Further Activities Application 5 for the TMS320C5416 DSK and for the TMS320C5510. Alien Voices. A very simple application showing the effect of modulation on audio frequencies. It shows how the carrier causes sum and difference frequencies to be generated. Here it is used to generate the strange voices used for aliens in science fiction films and television. ESIEE, Slide 70 Copyright © 2003 Texas Instruments. All rights reserved.