<< Chapter < Page Chapter >> Page >

We now provide an explanation of the shell C program main.c . The main.c file contains the main function that sets up the McBSP (Multi Channel Buffered Serial Port), DMA (Direct Memory Access), and interrupts. Then it returns and allows the DSP/BIOS scheduler to take over.

Many of the important interrupt routines are defined in the DSP/BIOS scheduler. The settings can be viewed by expanding the DSP/BIOS Config folder and double-clicking on the .cdb file. Changes do not have to be made, but it is good to know that the most important parts are the Scheduling and the Chip Support Library. Under Scheduling, there is the Hardware Interrupt Manager and Software Interrupt Manager. The Chip Support Library includes the DMA controller and the MCBSP. Various settings for these and many other modules can be set using a graphical interface instead of straight up coding.

Code for the DMA is defined in dma.c . The buffers are defined in this file, as well as the hardware interrupts. The hardware interrupts are initialized by calling the function init_DMA in the main function. When the hardware interrupts are triggered, they call the HWI_DMA0_Transmit() and HWI_DMA1_Receive() functions. At the end of these two functions, the software interrupt SWI_Process() is posted with different variables. Posting SWI_Process() will call the SWI_ProcessBuffer() function which will require modification.

The SWI_ProcessBuffer() function is defined in lab4.c . It is called every time the software interrupt SWI_Process is posted, which is set to happen every N = 1024 samples. As given, the function will simply copy the inputs to the outputs. (After commenting out some lines and uncommenting others.) Follow the example and comments to modify the code to perform the necessary operations.

Although each of these operations may be performed in C or assembly, we suggest you follow the guidelinessuggested.

  • Transfer inputs (C)
  • Apply a Hamming Window (C/assembly)
  • Bit-reverse the input (C and assembly) (Already done)
  • Apply an N -point FFT (C and assembly) (Already done)
  • Compute the magnitude-squared spectrum and place in output (C/assembly)
  • Include a trigger pulse (C/assembly)
Note: Bit-reversing and application of the FFT may be done in reverse order depending on implementation.

Near the beginning of the SWI_ProcessBuffer function, the input samples need to be copied to specific buffers for processing. In C, pointers may be used as array names so that pdest[0] is the first word pointed to by pdest . The input samples are not in consecutive order and must be accessed with offsets. The four channels of input are offset from psrc respectively by 4 i and 4 i 2 , i 0 , …, BlockLen 1 . The four output channels are accessed consecutively as offsetsfrom pdest . On channel 1 of the output, the input is echoed out. You are to fill channel 2 with the windowedmagnitude-squared FFT values by performing the operations listed above. For the first step, take a look at the way we make the DSPLIB cfft call to find out where to transfer the inputs to. (You may change the function call cfft to pass in different values if you like. Just remember that bit_rev() expects its input in a specific location.) Likewise, take a look at the C FFT code (declared in lab4fft.c to find out where to copy the inputs to.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing laboratory (ece 420 55x). OpenStax CNX. Jan 18, 2010 Download for free at http://cnx.org/content/col10397/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing laboratory (ece 420 55x)' conversation and receive update notifications?

Ask