<< Chapter < Page Chapter >> Page >

We now provide an explanation of the shell C program lab4main.c listed in Appendix A . The lab4main.c file contains the function interrupt void irq and a main program. The main program is an infinite loop over blocks of N 1024 samples. Note that while the DSP is executing instructions in this loop, interrupts occur every BlockLen samples. Inside the infinite loop, you will insert code to do the operations whichfollow. Although each of these operations may be performed in C or assembly, we suggest you follow the guidelinessuggested.

  • Transfer inputs and outputs (C)
  • Apply a Hamming Window (C/assembly)
  • Bit-reverse the input (C and assembly)
  • Apply an N -point FFT (C and assembly)
  • Compute the magnitude-squared spectrum (C/assembly)
  • Include a trigger pulse (C/assembly)

The function WaitAudio is an assembly function in the core code which handles the CODEC interrupts. An interrupt from the CODEC occurs every BlockLen samples. The SetAudioInterrupt(irq) call in the main program tells the core code to jump to the irq function when an interrupt occurs. In the irq function, BlockLen samples of the A/D input in Rcvptr (channel 1) are written to a length N inputs buffer, and BlockLen of the output samples in the outputs buffer are written to the D/A output via Xmitptr on channel 2. In C, pointers may be used as array names so that Xmitptr[0] is the first word pointed to by Xmitptr . As in the assembly core, the input samples are not inconsecutive order. The right and left inputs are offset from Rcvptr respectively by 4 i and 4 i 2 , i 0 ,, BlockLen 1 . The six output channels are accessed consecutively as offsetsfrom Xmitptr . On channel 1 of the output, the input is echoed out. You are to fill the buffer outputs with the windowed magnitude-squared FFT values by performing the operationslisted above.

In the main code, the while(!input_full); loop waits for N samples to collect in the inputs buffer. Next, the N inputs and outputs must be transferred. You are to write this portion of code. This portion of code is tobe done first, within BlockLen sample times; otherwise the first BlockLen of samples of output would not be available on time. Once this loop isfinished, the lengthy processing of the FFT can continue. During this processing, the DSP is interrupted every BlockLen samples to transfer samples. Once this processing is over, the infinite loop returns to while(!input_full); to wait for N samples to finish collecting.

The flow diagram in summarizes the operation of the interrupt handling routine

main
interrupt handler
Overall program flow of the main function and the interrupt handling function.

Assembly fft routine

As the list of operations indicates, bit-reversal and FFT computation are to be done in both C and assembly. For theassembly version, make sure that the line defining C_FFT is commented in lab4main.c . We are providing you with a shell assembly file, available at v:\ece420\54x\dspclib\c_fft_given.asm and shown in Appendix B , containing many useful declarations and some code. The code for performingbit-reversal and other declarations needed for the FFT routine are also provided in this section. However, we would like you to enter this code manually, as you will be expected to understand itsoperation.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ece 320 spring 2004. OpenStax CNX. Aug 24, 2004 Download for free at http://cnx.org/content/col10225/1.12
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 320 spring 2004' conversation and receive update notifications?

Ask