MicroII Lab1 Report

advertisement
ECE 3552-Microcomputer System 2
Spring 2007
LAB Exercise # 1:
Building and Running a C Program
On two Separate BF533 EZ-Kit Lit
Boards Communicating over RS232
UART Port
By
Lisa Schwartz
Partner: Pattarapong Rojanasthien
Purpose:
The purpose of this lab is to introduce the student to Distributed Processing and
Simulation of actual Communication Channel. The goal is to use one board to accept the
audio signal, compress it, and transmit the compressed data to other board via RS232
channel. The receiving board will uncompress data and play out the signal in real time.
Procedure:
1. Test UART example code making sure the data is being transmitted successfully
from one board to the other. Use the plotting ability of the VisualDSP++ IDE to
validate transmitted and received data.
2. Establish if the maximum UART transmission rate is sufficient to accommodate
two audio channel streams with 48 kHz.
a. Use the maximal Baud rate (bps) of UART as documented in the “ADSPBF533 Blackfin Processor Hardware Reference” manual.
b. Compute if two channels of 24-bit audio stream with 48 k samples per
second can be transmitted over UART.
c. Would the reduction of number of bits to 8-bits enable transmission over
UART? Compression of the data can be done with mu-law function
included in DSP’s C/C++ run-time library.
d. If the sample rate is too high one could down sample the original sample
rate for example by factor of 2 (i.e., 24 kHz). Down-sampling requires that
the bandwidth of the signal be band-limited to bellow the bandwidth of the
target prior to decimation. DSP’s run-time library provides both
decimation functions and interpolation functions to convert back to
original sample rate. For further information see the “Getting Started”
section of this document.
3. Combine Talk-through with UART example code, which is provided.
4. Alter Transmitter.
a. Use u-law compression to reduce 24-bit audio stream to 8 bits.
b. Send each channel as a consecutive 8 bit data over UART.
5. Alter Receiver.
a. Use inverse mu-law expansion to expand 8-bit audio stream to 24 bits.
b. Distribute two consecutive data points into two output audio channels.
Results:
When we first tested the UART code example, the plot on the receiver did not
form properly. This was discovered to be a result of the wrong cables being used. The
boards could not communicate properly with one another. After this problem was fixed,
the UART code was tested successfully by using the plot function of VisualDSP. It
showed that audio data was being sent and received properly.
The maximum UART transmission rate is not sufficient to for the two audio
channel streams with 48kHz. The default SCLK and CCLK values are 54 MHz and
270MHz, respectively. The baud rate is defined by the following equation (page 13-2 of
the ADSP-BF533 Blackfin Processor Hardware Reference):
Baud rate = SCLK / (16 * Divisor)
Where SCLK is the system clock frequency and Divisor can be a value
from 1 to 65536.
Thus, the maximum baud rate occurs when Divisor is smallest and SCLK is
largest. For a Divisor of 1 and SCLK at the default, the baud rate is 3,375,000. The
manual appears to state on page 13-1 that the maximum baud rate for our purposes is
115.2Kbps. This is due to a change in the Divisor. The data must be compressed and/or
shifted to be able to transmit. This is where the mu-law compression comes into play.
After the UART example code was combined with “Talkthrough.h”, the code was
tested again, with the output actually connected to the speakers. The resulting noise
heard was very close to the original audio, but of slightly lower quality. This is due to the
fact that the bits were merely shifted one way and then the other, so the least significant
bits were lost. It is similar to the effects due to rounding in mathematics. The results
were obvious to the human ear because the data was shifted 16 bits; from 24 to 8 and
back.
Since this high loss of precision is not generally accepted, an alternate method of
transferring the data must be implemented. Mu-law compression offers this option. The
input needs only to be shifted from 24 to 14 bits, saving 6 more bits of data than just
shifting. The 14-bit-data is then compressed to 8 bits, sent, and received. The receiver
then expands the data and shifts it back to 24 bits to output the audio data. The result is
very close in sound to the original audio file.
After many attempts and the discovery that mu-law compression takes 14-bit data
and not 16-bit data, the transmitter and receiver were both working. The code was
expanded to include data for the left and right speakers, as it was originally only coming
out of one. The code was also cleaned up so it could be read clearly and easily.
Conclusions:
The students discovered how data can be transmitted from one Blackfin to
another. This is highly interesting and opens up many new doors of opportunities for
other functions for the boards. Audio data was sent successfully from one computer to a
Blackfin processor, to another Blackfin, to a second computer. This all occurred in realtime, with no noticeable delay between the picture and sound of a music video on the
computer. For data to be sent through the RS232 channel provided by the cable
connecting the boards, the data needed to be limited to 8-bits. This was possible to
achieve by just shifting, or combining shifting with mu-law compression. Using the mulaw compression and expansion resulted in higher-quality audio output.
Code:
All code files are attached to email in zip directories. Major changes occurred in
the Process_data files of both the receiver and transmitter.
Download