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.

[参考译文] TMS320F28P659DH-Q1:CLA 警告:无效的类型转换

Guru**** 1853510 points
Other Parts Discussed in Thread: C2000WARE
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1435276/tms320f28p659dh-q1-cla-warning-invalid-type-conversion

器件型号:TMS320F28P659DH-Q1
Thread 中讨论的其他器件:C2000WARE

工具与软件:

尊敬的专家:

美好的一天! 我要求为客户提供服务。

我的客户在使用 第二条指令时在 CLA 中找到一条警告"无效类型转换"。

为了重现此问题、我对演示进行了修改。 如果我在 CLA 中添加了以下指令:"((struct adc_regs_test *)(unsigned long int) 0x00007600)->a = 0;"、它会在 CLA 中显示以下警告: #173-D INVALID type conversion cla_ex1_asin_cla.cla /Cla_ex1_asin line 115 C/C++ problem。

如果我 将"unsigned long int"更改为"unsigned short int"、警告将消失。

客户有以下问题:

1. CLA 中有多少位是"unsigned short int"和"unsigned long int"?  

2. 为什么 unsigned short int 没有警告、而 unsigned long int 有警告?

3. 因为客户现在想要写入 PWM 寄存器的32位地址。 客户在此处应使用哪种类型的变量?

您能帮助检查一下这些问题吗?

谢谢!

此致

Kita.

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Kita:

    1. CLA 中有多少位是"unsigned short int"和"unsigned long int"?  [报价]

    unsigned short int 为16位

    unsigned long int 为32位

    2.  为什么 unsigned short int 没有警告、而 unsigned long int 有警告?[/QUOT]

     CLA 只有16位寻址。

     在 CLA 上、常量的类型为32位(与 int 相同)、指针的类型为16位。  那么、会发生缩小转换范围的情况、编译器会对此发出警告。  

    请参阅本文档中的4.6  4.常见问题解答—C2000 CLA 软件指南

    仅供参考、请注意 CLA 的整数大小为32位、而 C28x 为16位。 为了避免在 CLA 和 C28x 之间共享数据时出现歧义、强烈建议使用包含大小信息的类型声明(例如、int32和 uint16)。  CLA 的指针大小始终为16位。 这与具有32位指针的 C28x 不同。  

    
    
    3.  因为客户现在需要写入 PWM 寄存器的32位地址。 客户应在此处使用哪种类型的变量?[/QUOT]

    您可以参阅[安装路径]\C2000Ware_5_03_00_00\driverlib\f28p65x\epwm.h 文件以查找有关如何写入寄存器的示例。

    例如、以下示例:

    HWREGH (BASE + ePWM_O_TBCTR)=计数

    谢谢!
    Susmitha

    [/quote]
    [/quote][/quote]