6.6: DSP Algorithms
6.6: DSP Algorithms
If not otherwise declared, the following description holds for both the conventional FFT and the FFT with phase error correction algorithms.
The software executable code comes from assembling and linking the objects of four distinct programs: the main program (Main), an interrupt service routine, an FFT routine, and a procedure to translate the floating point values, which use standard IEEE representation in host environment, to the Texas Instrument (TI) representation, used by the DSP, and vice versa.
All this code has been written in assembly language. The resulting executable code has been placed on the ONCHIP memory. All the pointers to the different memory locations have been placed in the same memory space where the executable code is, in order to reduce a continuous paging. On the other hand, the variables with the LabVIEW addresses have been placed in the Dual Access memory because this is the only area the host can access directly without using interrupts. In fact, the use of interrupts, in this specific case, will result in a more complex code with a degradation of the execution time performance. Always in Dual Access memory, we allocated space for the lookup tables, which values are calculated in LabVIEW, and the data to be processed. This lets us, upon format conversion, a direct data transfer from the DSP to the hosting Macintosh.
The Main program performs the following tasks:
1.It disables the interrupts number 1 and 2 respectively for the RTSI bus and the DMA.
2.It loads the control parameters from LabVIEW, which already passed to the DSP their addresses in the host. Then reads on how many points and channels it has to perform the FFT, and stores these values in the Dual Access memory.
3.After initialising the pointers to the different buffers, whose number depends on the number of channels used, it loads the lookup tables of the selected window from LabVIEW. It makes the floating-point conversion from the IEEE representation to the TI one. It loads and converts the lookup table for the FFT butterflies.
The FFT with phase error correction requires a further lookup table with the exponential weights for the harmonics (see previous sections.) This step does not exist for the conventional FFT.
1.It initialises the variables that represent the argument to be passed to the FFT routine. At this point, the phase of reading the LabVIEW parameters is completed, and the Main clears the flag about the “change of parameters” on the host.
2.It loads the interrupt vector 1.
3.It configures the DSP Control Register and clears all the data memory buffers.
4.It configures the internal timer and the addresses where to write into the acquisition boards. It loads the address of the Soft A/D Clear Strobe Register of the acquisition boards, in order to clear their FIFO memories.
5.It enables the interrupt 1 for the acquisition data ready, because in this time the sampling is already started. From here, the real time processing also starts.
6.The Main starts the “wait” loop where the processing resides along with the data transfer to the hosting Macintosh: first, the Main is in an IDLE state waiting for the interrupts. For each interrupt, the Main leave its idle state and check, first of all, whether or not the LabVIEW set the “end-of job” and/or the “change of parameters” flags. In the former case, it halts the execution and jumps to the end of the program. In the latter case it jumps to the beginning of the program (step 1.)
7.It then checks the number of received interrupts in order to understand if there are enough data to start the processing. In fact, in case of four channels, for instance, for each acquisition interrupt, there are 512 points per board (256 per channel) in the DSP Dual Ported memory. To be able to perform a 1024 points FFT, it needs to wait for 4 interrupts.
8.Once there are enough data, it starts the nested loops of the FFT1 per channel. Before calling the FFT routine, the data are weighted with values taken from the lookup table of the selected window.
Only for the algorithm one with phase error correction, there is a further step about the data ordering and harmonics weighting with the values coming from the exponentials lookup table (see figure 6.3.)
1.A processing stage is completed. The Main change the floating point representation of the data to the IEEE format, consistent with the Macintosh environment, and then send the data to the host memory, so that can be displayed. The code jumps back to the step 9 to wait for new interrupts.
2.The last step. The Program Counter is here only if LabVIEW set the “end-of-job” flag. Before entering in the IDLE state, the DSP enables the interrupt letting the host to download a new application. It is at this time that the DSP is not the Master anymore, and waits for new instructions.
Concerning the interrupt service routine, its tasks are the following
1.It saves all the DSP registers on the stack.
2.It configures the DMA Controller for the data block transfer mode from the acquisition boards to the DSP Dual Ported memory. The input samples are packed so that for each transferred word there are two one-word samples.
3.It checks if the transfer is completed by polling.
4.Once the data transfer via DMA from the first acquisition board is completed, it prepares the data transfer from the second acquisition board.
5.The DSP starts to unpack the data sent by the first acquisition board and places the unpacked data into the Dual Access memory. In the meanwhile, the new data are coming from the second acquisition board via DMA over the NuBus.
6.It checks if the transfer from the second acquisition board is completed by polling.
7.The DSP starts to unpack the data sent by the second acquisition board and places the unpacked data into the Dual Access memory.
8.It restores the DSP registers from the stack and returns to the Main program.
The data unpacking and transferring is different depending on the number of channels in use. In fact, the algorithm has to understand from which of the channels the unpacked data come from, and has to place it in the proper Dual Access memory location consequently.
For the floating-point format conversion routines, we used and corrected, the routines quoted by the National Instruments manuals.
1 One FFT for the conventional case and two FFTs for the one with phase error correction.