Digital Signal Processing Reference
In-Depth Information
// RTDX_MATLAB_sim.c MATLAB-DSK interface using RTDX between PC & DSK
#include <rtdx.h> //RTDX support file
#include "target.h" //for init interrupt
short buffer[10] = {0}; //init data from PC
RTDX_CreateInputChannel(ichan); //data transfer PC-->DSK
RTDX_CreateOutputChannel(ochan); //data transfer DSK-->PC
void main(void)
{
int i;
TARGET_INITIALIZE(); //init for interrupt
while(!RTDX_isInputEnabled(&ichan)) //for MATLAB to enable RTDX
puts("\n\n Waiting to read "); //while waiting
RTDX_read(&ichan,buffer,sizeof(buffer));//read data by DSK
puts("\n\n Read Completed");
for (i = 0; I < 10; i++)
buffer[i]++; //increment by 1 data from PC
while(!RTDX_isOutputEnabled(&ochan)) //for MATLAB to enable RTDX
puts("\n\n Waiting to write "); //while waiting
RTDX_write(&ochan,buffer,sizeof(buffer));//send data from DSK to PC
puts("\n\n Write Completed");
while(1) {}
// infinite loop
}
FIGURE 9.6. C program that runs on the DSK to illustrate RTDX with MATLAB.
The buffer of data is incremented by one on the DSK and sent back to MATLAB
( rtdx_matlab_sim.c ).
the MATLAB on the PC to the C6x on the DSK and an output channel to trans-
fer data from the target DSK to the PC host. When the input channel is enabled,
data are read (received as input to the DSK) from MATLAB. After each data value
in the buffer is incremented by 1, an output channel is enabled to write the data
(sent as output from the DSK) to MATLAB. Note that the input (read) and output
(write) designations are from the target DSK.
Figure 9.7 shows the MATLAB-based program rtdx _ matlab _ sim.m . This program
creates a buffer of data values 1, 2,...,10.It requests board information, opens
CCS and enables RTDX. It also loads the executable file rtdx _ matlab _ sim.out within
CCS and runs the program on the DSK. Two channels are opened through RTDX:
an input channel to write/send the data from MATLAB (PC) to the DSK and an
output channel to read/receive the data from the DSK.
Build this project as rtdx_matlab_sim within CCS. The appropriate support
files are included in the folder rtdx_matlab_sim . Add the necessary support
files: the C source file rtdx _ matlab _ sim.c , the vector file intvecs.asm (from TI),
c6713dsk.cmd (from TI), rtdx.lib (located in c6713\c6000\rtdx\lib ), and the interrupt
support header file target.h (from MATLAB). This process creates the executable
file rtdx _ matlab _ sim.out .
Search WWH ::




Custom Search