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.

CLA与TMS320F28069中(unsigned int)字节长度不一样,如何设置使其长度一致,防止数据交互时出错

Other Parts Discussed in Thread: TMS320F28069

您好,我在使用TMS320F28069和其CLA功能时,将数据类型定义为unsigned int后,在CLA中读取ADC数据和进行unsigned int数据交互时,出现数据不正确,请问一下该如何设置。

  • 请将数据类型定义为Uint16,CLA默认的int占用32位。

  • 对呀,就是出现这个问题,我MCU中将数据类型定义为Uint16位,而CLA中int是32位的,在读取ADC的结果寄存器时就出问题了,在MCU中ADC结果寄存器值是正确的,但是在CLA中因为int是32位的所以读取ADC值就出错了,请问这个问题该怎么解决啊?

  • 能否将CLA中的数据也定义成Uint16类型。

  • 首先建议你参考如下链接:

    http://processors.wiki.ti.com/index.php/C2000_CLA_C_Compiler 

    问题分析:

    CLA中对于int类型会解析为32bits数据,而CPU会解析为16bits数据,从而可能导致CPU从CLA中取数的时候会导致错误;

    另外注意指针的问题;

    解决方案: 

    对于16bits数据,你可以定义为short类型, 对于32bits数据,可以定义为long类型,这样对于CPU和CLA解析都是一致的;

    另外你可以参考TI CLA头文件对Uint16和Uint32位的定义,从而保证不会出问题

    CLA  F2806x_Cla_typedefs.h 头文件的定义为:

    #ifndef DSP28_DATA_TYPES
    #define DSP28_DATA_TYPES
    typedef short int16;
    typedef long int32;
    typedef unsigned char Uint8;
    typedef unsigned short Uint16;
    typedef unsigned long Uint32;
    typedef float float32;
    typedef long double float64;
    #endif

    CPU的头文件定义是:F2806x_Device.h

    写在最后的,你可以查看下CLA例程中头文件的包含顺序,这种顺序保证CLA的类型定义是优先被使用而且数据类型是定义正确的!

  • 楼上解释的很全,这边还有一个文档可帮助到您,编译器datatype  http://www.ti.com/lit/ug/spru514n/spru514n.pdf  6.4 Data Types 第103页 以及10.2.1 Characteristics 192页。