<< Chapter < Page | Chapter >> Page > |
The USB port on the DSP box can also be used to transmit data between the DSP and the PC during real-time operation. Texas Instruments came up with Real Time Data Exchange (RTDX) to allow users real-time bidirectional exchange of data between the target and host. This allows the simulation of data input and output which can be used as feedback from the DSP for a variety of applications. Both input and output data are buffered until read, allowing transmission of larger amounts of data.
The RTDX works by setting up input and output channels to the DSP. RTDX functionality is supplied through the include file
rtdx.h
so be sure it is included in your
main.c
and any other files that use rtdx functions.
Depending on whether there will be input and/or output from the computer in your project, add input and output channels in the
main.c
file using the commands. These are declared like global variables near the top of the code after the include files. They do NOT go in the main() function or any other function.
RTDX_CreateInputChannel(ichan);
RTDX_CreateOutputChannel(ochan);
By default, these channels are disabled on the DSP. You may enable them in the main loop so that they will be enabled for the duration of the program. This can be accomplished with the following instructions:
RTDX_enableInput(&ichan);
RTDX_enableOutput(&ochan);
In other C files that utilize the declared input and output channels, you will need to declare the input and output channels again with an extern so that your files know what the variables are.
extern RTDX_input_channel ichan;
extern RTDX_output_channel ochan;
Lastly, RTDX
MUST be manually enabled on the DSP boards. Go to
Tools->RTDX->Configuration Control
and select 'Enable RTDX' in the window that opens. Another helpful window for debugging is the 'Channel Viewer Control' accessed through
Tools->RTDX->Configuration Control
. This window displays the number of completed and outstanding transfers between computer and board.
The data buffer can be written to in C, but requires the block method of input/output used in
Lab 4 and
Lab 5 . The sample-by-sample method used in Labs 1 through 3 will not work with RTDX.
RTDX functionality is supplied through the include file
rtdx.h
so be sure it is included in your
main.c
file and any other files that use rtdx functions.
There are several functions for transmitting and receiving data within the C environment:
RTDX_readNB()
takes three arguments: the first is a pointer to the input channel, the second is a pointer to the variable in which to store read data, and the third is the number of bytes to read. This is a non-blocking read, meaning if no data is available to be read, it will merely return. However, there will then be an outstanding read and the variable will be updated when some data is finally read. It returns 'RTDX_OK' on success, '0' on failure (the target buffer is full), and 'RTDX_READ_ERROR' when the channel is currently busy reading.RTDX_read()
also takes three inputs like
RTDX_readNB()
and but on successful read, it returns the number of bytes of data actually in the buffer. The difference from
RTDX_readNB()
is it's a blocking read, meaning
RTDX_read()
won't return until something is read. If the channel is busy or not enabled, 'RTDX_READ_ERROR' will be returned.RTDX_write()
takes three arguments: the first is the pointer to the output channel, the second is a pointer to the buffer containing the data to write, and the third is the size of the buffer in bytes. It returns an integer, non-zero on success and '0' on failure.RTDX_sizeofInput()
takes a pointer to an input channel and returns the number of bytes of data actually read from the buffer. It is used in conjunction with
RTDX_readNB()
after a read operation is completed.RTDX_channelBusy()
takes a pointer to an input channel and returns an int indicating the status of the channel. A return of '0' means the channel is not busy while non-zero means the channel is busy. This is usually used in conjunction with
RTDX_readNB()
to check if another read request needs to be issued.Notification Switch
Would you like to follow the 'Digital signal processing laboratory (ece 420 55x)' conversation and receive update notifications?