STM32:未初始化的变量?
使用uvision IDE进行STM32开发,我想要一些定时器变量在启动时不初始化。我已经尝试过:
volatile unsigned int system_time __attribute__((section(".noinit")));
但
__attribute__((zero_init)) volatile int system_timer;
似乎没有任何效果。按照其他地方的提示,我还检查了 options/target/IRAM1 中的 NoInit。 尽管如此,重置后变量仍设置为零。
有人可以帮忙吗?
using the uvision IDE for STM32 development, I want to have some timer variables not initialized at startup. I have tried:
volatile unsigned int system_time __attribute__((section(".noinit")));
and
__attribute__((zero_init)) volatile int system_timer;
but nothing seems to work. Following the hints from elswhere, I have additionally checked NoInit at options/target/IRAM1.
Still, the variables are set to zero after reset.
Can anybody help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要按照以下步骤操作。
如下声明变量:
然后,您必须使用分散文件来声明具有 NOINIT 属性的执行部分,并将其与链接器一起使用。
分散文件示例:
You need to follow these steps.
declare your variable as follows:
Then you have to use a scatter file to declare the execution section with the NOINIT attribute and use it with the linker.
example scatter file:
您必须从 .MAP 文件中检查该变量的地址,并使用 at 关键字
允许您指定 C 源文件中未初始化变量的地址。 下面的例子
演示了如何使用at关键字来定位几种不同的变量类型。例如……
希望对解决您的问题有所帮助。
You have to check the address of that variable from .MAP file and use the The at keyword
allows you to specify the address for uninitialized variables in your C source files. The
following example demonstrates how to locate several different variable types using the at keyword.for example......
I hope it helps for solving your problem.