Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP.

Similar presentations


Presentation on theme: "EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP."— Presentation transcript:

1 EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP Debarati Kundu

2 2 Outline Sine Wave Generation  Function Call  Lookup Table  Difference Equation Output Methods  Polling  Interrupts  EDMA

3 3 Sine Wave Generation One-sided discrete-time signal of frequency ω 0 cos(ω 0 n) u[n] One-sided continuous-time signal of frequency ω 0 cos(2 π f 0 t) u(t) Using a sampling frequency f s such that f s > 2 f 0 Substitute t=nT s =n/f s f s cos(2π (f 0 /f s ) n) u[n] ω 0 = 2π (f 0 /f s ) rad/sample

4 4 Sine Wave Generation Function Call: Use the C library function sin(x) whenever a sine value is needed, approximated as the ratio of 2 10 th order polynomials in x  Computation: 21 multiplications, 21 additions and 1 division  Memory Usage: 22 coefficients and 1 intermediate variable (x) and one constant (2  ) Lookup Table: Pre-compute and store one period of samples, can even store one-half or one-quarter or one-eighth period and use symmetry.  Frequency is ω 0 =2πN/L  L is the period in discrete-time  Interpolate stored values to get result at all frequencies  No computation needed, just memory reads.

5 5 Sine Wave Generation Difference Equation: Input x[n] and output y[n] (zero IC’s) y[n] = (2 cos  0 ) y[n-1] - y[n-2] + x[n] - (cos  0 ) x[n-1]  Results from z-transform of cos(ω 0 n)u[n]  Computation: 2 multiplications and 3 additions  Memory Usage: 2 coefficients, 2 previous values of y[n] and 1 previous value of x[n]  Drawback is the build-up of error due to feedback

6 Polling: CPU Poll RRDY ADC McASP DAC SR12 SR11 Poll XRDY DATA AIC3106 Audio Codec READ SR12 WRITE SR11 Poll XRDY (transmit ready) bit of the McASP(Multi-Channel Audio Serial Port) until TRUE then write to SR11 register of the McASP. If XRDY is TRUE, function returns the sample and the value 1, If XRDY is FALSE, function returns immediately without sending a sample and return the value 0. 4

7 7 Output Methods Drawbacks of Polling:  Most of the time in the polling method is spent in the infinite loop waiting for the RRDY/XRDY flag to get set,  DSP is doing nothing,  A more efficient approach is to let DSP run tasks in background (modulating/demodulating, coding/decoding…),  So, serial port will interrupt background tasks when sample is received and needs to be transmitted.

8 8 Output Methods Interrupts: are signals from hardware/software indicating the need for attention or change of execution. C6748 DSP has a vectored priority interrupt controller that can handle 16 different interrupts:  RESET interrupt has highest priority, cannot be masked,  NMI (Non-Maskable Interrupt) has the second highest priority (used to notify DSP of serious hardware errors),  2 reserved maskable interrupts come next,  12 additional maskable interrupts (INT4-INT15) have the lowest priority.

9 CPU Interrupts from McASP “Ready to Read” CPU CODECCODEC McASP0_INT RDATA=1 SR12XRSR SR11XRSR XDATA=1 “Ready to Write”  RCV/XMT INTs combined into one interrupt:MCASP0_INT  RDATA triggers when SR12 is filled (32 bits)  XDATA triggers when SR11 is emptied (32 bits) 7

10 How do Interrupts Work? 1. An interrupt occurs EDMA McASP Timer Ext’l pins 2. Interrupt Selector 124+4 12 3. Sets flag in Interrupt Flag Register (IFR) … 4. Is this specific interrupt enabled? (IER) 5. Are interrupts globally enabled? (GIE/NMIE) 6. CPU Acknowledge Auto hardware sequence HWI Dispatcher (vector) Branch to ISR 7. Interrupt Service Routine (ISR) Context Save, ISR, Context Restore  User is responsible for setting up the following: #2 – Interrupt Selector (choose which 12 of 128 interrupt sources to use) #4 – Interrupt Enable Register (IER) – individually enable the proper interrupt sources #5 – Global Interrupt Enable (GIE/NMIE) – globally enable all interrupts #6 – Hardware Interrupt (HWI) Dispatcher – the vector to the ISR 12

11 11 Example Interrupt Service Routine interrupt void Codec_ISR() { /* add any local variables here */ if(CheckForOverrun())// overrun error occurred (i.e. halted DSP) return;// so serial port is reset to recover CodecDataIn.UINT = ReadCodecData();// get input data samples /* algorithm begins here */ phaseIncrement = 2*pi*fDesired/fs; /* calculate the phase increment */ phase += phaseIncrement; /* calculate the next phase */ if (phase >= 2*pi) phase -= 2*pi; /* modulus 2*pi operation */ CodecDataOut.Channel[ LEFT] = A*sinf(phase); /* scaled L output */ CodecDataOut.Channel[RIGHT] = A*cosf(phase); /* scaled R output */ /* algorithm ends here */ WriteCodecData(CodecDataOut.UINT);// send output data to port }


Download ppt "EE 445S Real-Time Digital Signal Processing Lab Fall 2013 Lab #2 Generating a Sine Wave Using the Hardware & Software Tools for the TI TMS320C6748 DSP."

Similar presentations


Ads by Google