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.

[参考译文] MSP430G2744:IAR 不支持打包的位域?

Guru**** 2535750 points
Other Parts Discussed in Thread: MSP430G2744

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/591725/msp430g2744-iar-not-supporting-packed-bitfield

器件型号:MSP430G2744

MSP430G2744、IAR 7.10.2

我正在 IAR 中测试程序、但我发现压缩结构中的位字段不正确。

代码如下所示:

#define RF_MSG_HEADER_downlink \
uint8长度;/*消息长度(不包括 ME)*/\
uint8 RecvAddr;\
uint8 SendAddr;\
uint8 Content_SenderBase 类型:1;\
uint8 Content_MessageID:7;

tystructure _ Downstruction__(packed)
{
rf_Headrf_link_rgmsg
;}




在调试过程中、我可以看到解压缩结构的地址和"Content_SenderBase 和"Content_MessageID"的值是正确的、但它们对于压缩结构不正确。 地址是结构的起始地址。
IAR 不支持打包结构中的位字段吗? 在编译器用户指南中、似乎没有说明当 packed 与 bitfield 混合时会发生什么情况。
有人有什么想法吗?

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

    此问题实际上与 MSP 产品无关、您是否尝试联系 IAR 支持?

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

    还没有。

    现在我发现 IAR 可能不支持__attribute__(((packed)。 可能需要改用#pragma pack (1)。