For the next two labs, we will make the 56002 act as a spectrum analyzer. That is, we will find an approximation of the energy density spectrum of an input signal x(n):
The approximation we will use for X(w) is the Discrete Fourier Transform (DFT). We won't discuss the DFT or how to calculate it until later in the semester, but numerous well-coded DFT routines exist, and we will use one of them.
What we need to do is to read in a block of data from the A/D converter (say, 1024 samples), calculate its DFT, find the squared magnitude, and write this out to the D/A converter. It takes time to calculate the DFT, so while we're calculating the DFT, we want to make sure we continue reading data in through interrupts. Thus, we need several buffers -- space to read data into, space to store the data we want to write out, and space to do the calculations. Next weeks lab will be concerned with the actual calculation of Sxx(w). This week, we will write a program which will properly manage the buffers. This will give you a good deal of experience with the address pointers of the 56002.
In this lab, we will deal with two buffers. Let's call one the write/read buffer and the other the calculation buffer. We assume that the write/read buffer has Sxx(w) in it. When new data comes in we need to write out Sxx(w), then x(n) into that now-available space. All of this needs to be done via interrupts so we can (next week) calculate Sxx(w) while the I/O is taking place. After 1024 new samples have been read in, we will switch the write/read and calculation buffers, and write out the newly calculated Sxx(w). Use address pointer r2 to keep track of the current location in the 2 Kword buffer. All the other pointers will be used by the DFT routine.
This lab will be concerned with learning about address pointers on the 56002, and about how to fill the buffers properly in the interrupt service routines.
ssi_rx_isr
(in the file txrx_isr.asm
) which will, when it
gets a Receive Data Interrupt, do the following if this is a new frame:
RX_BUFF_BASE
)
to be transmitted out the left channel (to TX_BUFF_BASE
).
TX_BUFF_BASE + 1
).
RX_BUFF_BASE
)
to the 2 Kword buffer for later processing.
DO #100,end_do_1 NOP DO #500,end_do_2 NOP end_do_2 NOP NOP end_do_1
Here is an example of how you could do it in C:
while (TRUE) { if (r2 == BUF1) { bring_tio_high(); process_BUF2(); bring_tio_low(); } else if (r2 == BUF2) { bring_tio_high(); process_BUF1(); bring_tio_low(); } }Sxx.
When done with today's lab, your DSP's left channel should be the same as the input signal, your DSP's right channel should be the input signal delayed by 2048 samples, and your TIO pin should send out a pulse every 1024 samples. Verify this using a function generator and oscilloscope.