目前在使用 CCS5.4调试F2808,想实现一个功能:将DSP中的某个变量不断写入PC上的某个.txt文件中。
想使用fopen、fwrite这类函数,但调试过程中总是出现这样那样的错误,所以想请教一下,这种想法理论上是否可以实现?如果可以,或者有哪位大侠之前做过,能不能告知一下,需要进行哪些设置??
谢谢!!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
目前在使用 CCS5.4调试F2808,想实现一个功能:将DSP中的某个变量不断写入PC上的某个.txt文件中。
想使用fopen、fwrite这类函数,但调试过程中总是出现这样那样的错误,所以想请教一下,这种想法理论上是否可以实现?如果可以,或者有哪位大侠之前做过,能不能告知一下,需要进行哪些设置??
谢谢!!
你好 请参考下面代码
#include<stdio.h>
#define MODEGRAYBAR 0
#define MODEGRAY 1
#define MODEPHOTO1 2
#define MODEPHOTO2 3
#define MODEPHOTO3 4
#define MODEPHOTO4 5
#define MODEBLOCK 6
#define MODEINCLINE 7
#define MODEFPHOTO 8
#define GRAYBARLEVEL 16
void ReadImage(unsigned char *pImage,char *cFileName,int nWidth,int nHeight);
void InitImage(unsigned int nMode,unsigned char *pImage,int nWidth,int nHeight)
{
int x,y,nWork,nWork1;
unsigned char *pWork;
int nPointx=nWidth/2;
int nPointy=nHeight/2;
switch ( nMode )
{
case MODEGRAYBAR:
pWork=pImage; nWork=256/GRAYBARLEVEL; nWork1=nHeight/GRAYBARLEVEL;
for ( y=0;y<nHeight;y++ )
{
for ( x=0;x<nWidth;x++,pWork++ )
{
(*pWork)=(y/nWork1)*nWork;
}
}
break;
case MODEGRAY:
pWork=pImage;
nWork1=nHeight-nPointy; nWork=nWork1*nWork1;
nWork1=nWidth-nPointx; nWork+=(nWork1*nWork1);
nWork/=256;
for ( y=0;y<nHeight;y++ )
{
for ( x=0;x<nWidth;x++,pWork++ )
{
nWork1=(x-nPointx)*(x-nPointx)+(y-nPointy)*(y-nPointy);
nWork1=255-nWork1/nWork;
if ( nWork1<0 ) nWork1=0;
else if ( nWork1>255 ) nWork1=255;
(*pWork)=nWork1;
}
}
break;
case MODEPHOTO1:
ReadImage(pImage,"..\\Sunplus1.bmp",nWidth,nHeight);
break;
case MODEPHOTO2:
ReadImage(pImage,"..\\Sunplus2.bmp",nWidth,nHeight);
break;
case MODEPHOTO3:
ReadImage(pImage,"..\\Sunplus3.bmp",nWidth,nHeight);
break;
case MODEPHOTO4:
ReadImage(pImage,"..\\Sunplus4.bmp",nWidth,nHeight);
break;
default:
break;
}
}
void ReadImage(unsigned char *pImage,char *cFileName,int nWidth,int nHeight)
{
int j;
unsigned char *pWork;
FILE *fp;
if ( fp=fopen(cFileName,"rb" ) )
{
fseek(fp,1078L,SEEK_SET);
pWork=pImage+(nHeight-1)*nWidth;
for ( j=0;j<nHeight;j++,pWork-=nWidth )
fread(pWork,nWidth,1,fp);
fclose(fp);
}
}
亲自实验证明,是可以实现的,不过在时间上是有要求的,不试所有条件下都可以