TI论坛
直播中

h1654155275.5724

7年用户 212经验值
私信 关注
[问答]

在CCS5.4下能实现将DSP中的某个变量不断写入PC上的某个.txt文件中吗

目前在使用 CCS5.4调试F2808,想实现一个功能:将DSP中的某个变量不断写入PC上的某个.txt文件中。
想使用fopen、fwrite这类函数,但调试过程中总是出现这样那样的错误,所以想请教一下,这种想法理论上是否可以实现?如果可以,或者有哪位大侠之前做过,能不能告知一下,需要进行哪些设置??
谢谢!!

回帖(4)

张琛根

2018-11-29 15:31:17
受到警告
提示: 作者被禁止或删除 内容自动屏蔽
举报

胡红枚

2018-11-29 15:40:50
你好  请参考下面代码
#include
#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    [
    for ( x=0;x     [
     (*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    [
    for ( x=0;x     [
     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    fread(pWork,nWidth,1,fp);
  fclose(fp);
 ]
]
 
举报

h1654155275.5724

2018-11-29 15:55:11
引用: oiewjrj 发表于 2018-11-29 08:39
你好  请参考下面代码
#include<stdio.h>
#define MODEGRAYBAR 0

十分感谢
举报

h1654155275.5724

2018-11-29 16:10:44
引用: 天天雷锋 发表于 2018-11-29 08:29
你的代码运行在dsp中,你怎么来打开pc机上的文件呢?fopen、fwrite这类函数本来就不是给我们搞单片机的人玩的。
所以你还是使用上位机来读取dsp中数据吧。

亲自实验证明,是可以实现的,不过在时间上是有要求的,不试所有条件下都可以
举报

更多回帖

发帖
×
20
完善资料,
赚取积分