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.

关于CCSV6.1中的dat文件数据在MATLAB中读取问题

Other Parts Discussed in Thread: TMS320F28335

您好!项目中使用主芯片TMS320F28335,在CCSV6.1中通过菜单“Tools”->"Save Memory"保存某一个数组a(数据类型uint16)的数据到dat文件,

下面是选择16-Bit Hex-C style格式保存的dat文件数据的一部分:

1651 9 ccc0 1 9c0 0
0x0001
0x0100
0x0001
0x0200
0x0001
0x0300
0x0001
0x0400
0x0001
0x0500
0x0001
0x0600
0x0001
0x0700
0x0001
0x0800
0x0001
0x0900
0x0001
0x0A00
0x0001
0x0B00
0x0001
0x0C00
0x0001
0x0D00
0x0001
0x0E00

在MATLAB中采用fread函数(Read data from binary file)和fscanf(Read data from text file)函数读取该dat文件,A = fread(fileID,sizeA,precision) interprets values in the file according to the form and size described by precision. The sizeA argument is optional. MATLAB代码如下:

fid=fopen('F:\hxn\TEST\DATA\RD2.dat','r');
fseek(fid,6,'bof');
a=fread(fid,file_length,'uint16=>uint16');

使用fread提取出的数据如下(已经跳过了前6个代表文件头的数据):

25376
25443
8240
8241
25401
8240
3376
12298
12408
12336
3377
12298
12408
12337
3376
12298
12408
12336
3377
12298
12408
12338
3376
12298
12408
12336
3377
12298
12408
12339
3376
12298
12408
12336
3377
12298
12408
12340
3376
12298
12408
12336

以上提取出的数据跟dat文件中实际数据不一致,明显是错误的,使用其他几种16位的数据格式保存dat文件读取的数据也是错误的,请问上图中CCSV6.1中Save Memory时各种数据格式Format最终保存的dat文件到底是什么格式的?是二进制格式文件还是txt格式文件?还是其他的什么格式文件?CCSv6.1内存数据在产生的dat文件中是如何存放的?应该怎样正确提取dat文件的数据,TI官方有没有CCS各版本产生的dat文件相关的技术文档资料?有的话麻烦发一下链接网址,谢谢!

  • 问题不在ccs保存段,保存的时候,格式就是你上面贴出来的数据格式。应该是matlab读取函数的使用上,再好好研究一下看看有什么问题。之前保存都是用的cvs,matlab中可以很方便导入。

  • 你从CCS中到处后你通过工具打开看看  是不是导出的数组

    我觉得fread应该不会出问题