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.

dsp2000中unsigned char型数据问题

在2812中定义了unsigned char 变量     为啥在仿真查看变量值的时候发现都是16位的呢

  • 楼主你好!

    C2000中最小数据位宽为16bit。参考下图数据类型:

  • 谢谢你的回复    知道啦   非常感谢你

  • 还有问题想请教你   那如果我用SCI接收到一些数据   这些数据是8bit的   然后与我定义的unsigned char运算  运算的结果再次用SCI进行传输   这样是不是会出现问题   

  • 不会。C语言角度来看,是标准的8bit。只是机器寻址上不支持8bit数据而已。

  • 换ccs5.3版本的编译器呢?能不能改变寻址为8bit?

  • dragon,

    在CCS5.3也是一样的,这跟芯片相关,跟CCS无关。关于这个问题,下面有相应的解决方法,你可以参考,如果要进行8bits寻址,需要特殊指令。

    Solution:

    The smallest addressable memory cell on the F28xx is 16-bits.This is mentioned in the TMS320C28x C/C++ Language Implementation User's Guide (SPRU514) in Section 6.3 called Data Types.

    There are compiler instrinsics __byte() and __mov_byte() to access data in increments of 8-bits.

    This info from the TMS320C28x Optimizing C/C++ Compiler User's guide (SPRU514) may help (page 82):

    By ANSI/ISO C definition, the sizeof operator yields the number of bytes required to store an object. ANSI/ISO further stipulates that when sizeof is applied to char, the result is 1. Since the TMS320C28x char is 16 bits (to make it separately addressable), a byte is also 16 bits. This yields results you may not expect; for example, size of (int) = = 1 (not 2). TMS320C28x bytes and words are equivalent (16 bits).

    To access data in increments of 8 bits, use the __byte() and __mov_byte() intrinsics described in Section 7.4.4.

     

    Reference:

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/21671.aspx

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

    Eric

  • 不能,与CCS无关,这是C2000 内核的寻址结构决定的,16bit偶数地址对齐。