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.

[参考译文] CCS/MSP430FR5994:当目标地址超过16位时使用#pragma 位置?

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

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/868243/ccs-msp430fr5994-using-pragma-location-when-destination-address-exceeds-16-bit

器件型号:MSP430FR5994

工具/软件:Code Composer Studio

我需要在地址0x20000处放置一个变量。
从 MSP430FR5994数据表中删除了表6-41。 存储器组织、0x20000位于 FRAM 代码存储器内。
使用以下指令时:

#define 地址(8192 * 16)
#pragma LOCATION (变量、地址);
int 变量;

存在编译器警告:
"整数运算结果超出范围"

如果我在指令中显式放置该数字、编译器警告消失:

#pragma LOCATION (变量、0x20000);
int 变量;

那么、在#pragma 位置使用超过16位的地址是否安全? 编译器警告是否至关重要? 哪种方法是正确的?

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

    此表达式...

    [引用 user="zcua"](8192 * 16)

    (笑声) 不能用类型 int 表示。  在 MSP430上、int 是一个16位宽的有符号类型。  可以表示的最大正值为0x7fff、即32、767。  因此,编译器会发出此诊断...

    [引用 user="zcu"]"整数运算结果超出范围"

    通常的修复方法是通过添加后缀 L 将常量类型更改为 long

    (8192L * 16L) 

    谢谢、此致、

    乔治

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