本例程用DSP/BIOS实现,设定了四个任务线程,读函数没有操作,因为个人只想测试一下DSP通过JTAG向PC发送数据。
具体的函数参考DSP/BIOS API 手册,另外因为用到了RTDX,所以必须设置RTDX
主机口程序用VC++6.0写的
// rtdxint.cpp : Defines the entry point for the console application.
//
#import "F:MFC
tdxint
tdxint.dll"
#include "stdafx.h"
#include "rtdxint.h"
#include <iostream.h>
using namespace RTDXINTLib;
int main(int argc, char* argv[])
{
IRtdxExpPtr rtdx; // holds pointer to IRtdxExp interface
short data; // holds data received from target application
long status; // holds status of RTDX COM API calls
HRESULT hr; // holds status of generic COM API calls
// initialize COM
::CoInitialize( NULL );
// instantiate the RTDX COM Object
hr = rtdx.CreateInstance( L"RTDX" );
cout.setf( ios::showbase );
if ( FAILED(hr) ) {
cerr << hex << hr << " - Error: Instantiation failed!
";
return -1;
}
// open a channel (ochan) for reading data
status = rtdx->Open( "ochan", "R" );
if ( status ) {
cerr << hex << status
<< " - Error: Opening of channel "ochan" failed!
";
return -1;
}
// loop until we have read all of our messages
do {
// read a message
status = rtdx->ReadI2( &data );
// test status returned from ReadI2
switch ( status ) {
case Success:
//如何传输一个文件呢?
// display data
cout << data << "
";
break;
case Failure:
cerr << hex << status
<< " - Error: ReadI2 returned failure!
";
return -1;
case ENoDataAvailable:
cout << "
No Data is currently available!
";
cout << "
Would you like to continue reading [y or n]?
";
char option;
cin >> option;
if ( (option == 'y') || (option == 'Y') )
break;
else
return -1;
case EEndOfLogFile:
cout << "
Data Processing Complete!
";
break;
default:
cerr << hex << status
<< " - Error: Unknown return code!
";
return -1;
}
} while ( status != EEndOfLogFile );
RTDX提供了实时、连续了解目标系统程序运行情况的手段,它允许用户在不干扰目标系统程序运行的情况下,在主机和目标系统之间传送数据。目标系统与主机之间的RTDX实际上仍然是通过JTAG接口完成的,目标系统中的RDTX目标库和位于CCS中的RDTX主机库之间实时交换数据。
主机客户程序:运行在主机上利用COM接口项目表应用程序发送数据或者从目标应用程序接收数据的程序。
目标应用程序通过调用RTDX目标库中的函数发送数据。这些数据实际上只是放在RTDX目标库的缓冲区中,然后函数立即返回。RTDX目标库在处理器空闲时将本地缓冲区中的数据发送出去,这样就不干扰主应用程序的正常运行。RTDX主机库对外提供COM接口,可以认为是COM服务器,主机客户程序通过COM接口获取数据,并根据需要分析和显示数据。
同样,当主机应用程序向客户应用程序发送数据时,数据被放在RTDX主机库的缓冲区中。当RTDX主机库接收到目标应用程序要求数据的请求时,如果缓冲区中有足够的数据满足要求,数据就会发送到目标应用程序。数据被写入指定的存储器,不干扰目标应用程序运行,同时主机会通知RTDX目标库操作已经完成。
下面贴上DM642的DSP程序
//rtdxbios.c
#include <std.h>
#include <rtdx.h>
#include"target.h"
#include <stdio.h>
#include <log.h>
#include <tsk.h>
#include "rtdxbioscfg.h"
int arraydata[10];
Void reading(int n);
Void writing(int n);
Void processing(int n);
Void taskend();
Void main()
{
}
Void reading(int n)
{
}
Void writing(int n)
{
int status;
n=10;
LOG_printf(&trace,"writing");
status=RTDX_write(&ochan,&arraydata,4*n);//如何传输一个文件呢?
if ( status == 0 ) {
LOG_printf(&trace,"ERROR: RTDX_write failed! " );
exit( -1 );
}
LOG_printf(&trace,"has been writed to the host");
}
Void processing(int n)
{
int i;
n=10;
TARGET_INITIALIZE();
RTDX_enableInput(&ichan);
RTDX_enableOutput(&ochan);
LOG_printf(&trace,"begin");
LOG_printf(&trace,"processing");
for(i=0;i<n;i++)
{
arraydata=i;
}
}
Void taskend()
{
while ( RTDX_writing != NULL )
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
}
RTDX_disableInput(&ichan);
RTDX_disableOutput(&ochan);
LOG_printf(&trace, "Program Complete! " );
exit(-1);
}
本例程用DSP/BIOS实现,设定了四个任务线程,读函数没有操作,因为个人只想测试一下DSP通过JTAG向PC发送数据。
具体的函数参考DSP/BIOS API 手册,另外因为用到了RTDX,所以必须设置RTDX
主机口程序用VC++6.0写的
// rtdxint.cpp : Defines the entry point for the console application.
//
#import "F:MFC tdxint tdxint.dll"
#include "stdafx.h"
#include "rtdxint.h"
#include <iostream.h>
using namespace RTDXINTLib;
int main(int argc, char* argv[])
{
IRtdxExpPtr rtdx; // holds pointer to IRtdxExp interface
short data; // holds data received from target application
long status; // holds status of RTDX COM API calls
HRESULT hr; // holds status of generic COM API calls
// initialize COM
::CoInitialize( NULL );
// instantiate the RTDX COM Object
hr = rtdx.CreateInstance( L"RTDX" );
cout.setf( ios::showbase );
if ( FAILED(hr) ) {
cerr << hex << hr << " - Error: Instantiation failed! ";
return -1;
}
// open a channel (ochan) for reading data
status = rtdx->Open( "ochan", "R" );
if ( status ) {
cerr << hex << status
<< " - Error: Opening of channel "ochan" failed! ";
return -1;
}
// loop until we have read all of our messages
do {
// read a message
status = rtdx->ReadI2( &data );
// test status returned from ReadI2
switch ( status ) {
case Success:
//如何传输一个文件呢?
// display data
cout << data << " ";
break;
case Failure:
cerr << hex << status
<< " - Error: ReadI2 returned failure! ";
return -1;
case ENoDataAvailable:
cout << " No Data is currently available! ";
cout << " Would you like to continue reading [y or n]? ";
char option;
cin >> option;
if ( (option == 'y') || (option == 'Y') )
break;
else
return -1;
case EEndOfLogFile:
cout << " Data Processing Complete! ";
break;
default:
cerr << hex << status
<< " - Error: Unknown return code! ";
return -1;
}
} while ( status != EEndOfLogFile );
// close the channel
status = rtdx->Close();
// release the RTDX COM Object
rtdx.Release();
// unitialize COM
::CoUninitialize();
return 0;
}
RTDX 是通过JTAG接口实现DSP与PC的双向数据传输,JTAG接口决定了数据通信比特率很低,Kbps级别,用于实时调试还是蛮好,真要做大量数据传输就不合适了。
一周热门 更多>