打印
[其他ST产品]

在联合中使用section属性

[复制链接]
88|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
石榴大王|  楼主 | 2025-6-27 11:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在STM32 CubeIDE的项目中,我将一些存储区域分配到STM32H743ZITX_RAM.ld文件中定义的不同内存区域。

MEMORY{  DTCMRAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K  ITCMRAM    (xrw)    : ORIGIN = 0x00000000,   LENGTH = 64K  RAM_D1    (xrw)    : ORIGIN = 0x24000000,   LENGTH = 512K  RAM_D3    (xrw)    : ORIGIN = 0x38000000,   LENGTH = 64K  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 2048K} /* Sections */SECTIONS/* snip .. */  .myD3memory (NOLOAD):  {      . = ALIGN(4);     *(.myD3memory)    . = ALIGN(4);  } >RAM_D3/* etc .. */}
然后我可以在main()中使用它,如下所示:
uint16_t        buffer16[32768] __attribute__ ((section(".myD3memory")));
正Build Analyzer正确分配。但我想引用内存区域不是16位无符号短,而且是8位无符号字节,并尝试了以下方法:
union{    uint8_t        buffer8[65536] __attribute__ ((section(".myD3memory")));    uint16_t        buffer16[32768] __attribute__ ((section(".myD3memory")));}
产生错误:
../Core/Src/main.c: error: section attribute not allowed for 'buffer8'
uint8_t buffer8[65536] __attribute__ ((section(".myD3memory")));
../Core/Src/main.c: error: section attribute not allowed for 'buffer16'
uint16_t buffer16[32768] __attribute__ ((section(".myD3memory")));
请教如何解决

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

24

主题

24

帖子

0

粉丝