<< Chapter < Page Chapter >> Page >

Line 31 branches back to the top, where we wait for the next block to arrive and start over.

Using test vectors

A second version of the core file offers the same interface as the standard core file, but instead of reading inputsamples from the A/D converters on the six-channel board and sending output samples to the D/A converters, it reads andwrites from test vectors generated in MATLAB.

Test vectors provide a method for testing your code with known input. Given this known input and the specificationsof the system, we can use simulations to determine the expected output of the system. We can then compare theexpected output with the measured output of the system. If the system is functioning properly, the expected output andmeasured output should match

Will the expected output and the actual output from the DSP systemmatch perfectly? Why or why not?
.

Testing your system with test vectors may seem silly in some cases, because you can see if simple filters work by lookingat the output on the oscilloscope as you change the input frequency. However, they become more useful as you writemore complicated code. With more complicated DSP algorithms, testing becomes more difficult; when you correct an errorthat results in one case not working, you may introduce an error that causes another case to work improperly. This maynot be immediately visible if you simply look at the oscilloscope and function generator; the oscilloscope doesnot display the signal continuously and transient errors may be hidden. In addition, it is easy to forget to check allpossible input frequencies by sweeping the function generator after making a change.

More importantly, the test vectors also allow you to test signals that cannot be generated or displayed with theoscilloscope and function generator. One important signal that cannot be generated or tested with the functiongenerator and oscilloscope is the impulse function; there is no way to view the impulse response of a filter directlywithout using test vectors. The unit impulse represents a particularly good test vector because it is easy to comparethe actual impulse response of a digital filter against the expected impulse response. Testing using the impulseresponse also exposes the entire range of digital frequencies, unlike testing using periodic waveformsgenerated by the function generator.

Lastly, testing using test vectors allows us to isolate the DSP from the analog input and output section. This is usefulbecause the analog sections have some limitations, including imperfect anti-aliasing and anti-imaging filters. Testingusing test vectors allows us to ensure that what we see is due only to the digital signal processing system, and notimperfections in the analog signal or electronics.

After generating a test vector in MATLAB, save it to a file that can be brought into your code using the MATLAB command save_test_vector (available as save_test_vector.m ):

>> save_test_vector('testvect.asm',ch1_in,ch2_in); % Save test vector

(where ch1_in and ch2_in are the input test vectors for input channel 1 and input channel 2; ch2_in can be omitted, in which case both channels of the test-vector input will have the same data.)

Next, modify your code to include the test-vector support code and the test-vector file you have created. This can bedone by replacing the first line of the file (which is a linker directive to copy in core.asm ) with two lines. Instead of:

.copy "core.asm"

use:

.copy "testvect.asm" .copy "vectcore.asm"

Note that, as usual, the whitespace in front of the .copy directive is required. ( Download vectcore.asm into your work directory if you do not already have a copy.)

The test vectors occupy the .etext section of program memory between 08000h and 0FEFFh . If you do not use this section, it will not interfere with your program code or data. This memoryblock is large enough to hold a test vector of up to 4,000 elements. Both channels of input, and all six channels ofoutput, are stored in each test vector element.

Now assemble and load the file, and reset and run as usual. After a few seconds, halt the DSP (using the Halt commandunder the Debug window) and verify that the DSP has halted at a branch statement that branches to itself: spin b spin .

Next, the test vector should be saved and loaded back into MATLAB. This is done by saving 6 k memory elements (where k is the length of the test vector in samples, and the 6 corresponds to the six output channels) starting withlocation 08000h in program memory. Do this by choosing File->Data->Save... in Code Composer, then entering the filename output.dat and pressing Enter . Next, enter 0x8000 in the Address field of the dialog box that appears, 6 k in the Length field, and choosing "Program" from the drop-down menu next to "Page." (Always ensure that youuse the correct length - six times the length of the test vector - when you save your results.)

Last, use the read_vector function (available as read_vector.m ) to read the saved test vector output into MATLAB. Do thisusing the following MATLAB command:

>> [ch1, ch2, ch3, ch4, ch5, ch6] = read_vector('output.dat');

The MATLAB vectors ch1 through ch6 now contain the output of your program code in response to the input from the test vector.

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). OpenStax CNX. Sep 27, 2006 Download for free at http://cnx.org/content/col10236/1.14
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)' conversation and receive update notifications?

Ask