7

我正在使用具有 10K RAM 的 MSP430 芯片。如果我的 RAM 使用量超过 5k,它永远无法进入 main()。初始化代码调用__data20_memzero以清除已使用的 RAM 空间。

__data20_memzero 来源

看起来它在内存中递增并清除字节直到 R14=R12。R14 为 0x34B4。但是 R12 的最大值是 0x2c86 在它重新启动并重新开始之前。我通过调试器手动关闭了看门狗,它开始运行得很好。我不能认为这是正常的。知道如何解决这个问题吗?

4

2 回答 2

6

刚刚发布后,我发现了这个应用笔记

http://supp.iar.com/Support/?note=37778&from=search+result

如果应用程序有很多(超过 4k)的全局初始化数据,那么在看门狗超时(并且设备被重置)之前,cstartup 中的初始化不会完成。

The solution

The Watchdog timer must be turned off before the initialization phase. This should preferably be done in __low_level_init.

The steps (for F1610, F1611 or F1612)
Copy of the file "low_level_init.c" (from ...\430\src\lib\) to your project directory.
Add the copied "low_level_init.c" file to your project.
Edit your copy of the "low_level_init.c" file
In the file you need to add, either...

#include <msp430x16x.h>

...or add...

#include <io430x16x.h>

You should add, in the __low_level_init() function.

WDTCTL = WDTPW + WDTHOLD;
于 2013-07-28T07:22:34.363 回答
2

正如您所发现的,根本问题是初始化全局 ram 花费的时间太长。虽然在启动时禁用看门狗确实可以解决问题,但如果您担心 WD 被关闭(即使是暂时的),可能存在一种替代方法来缩短该初始化时间。

IAR 支持扩展__no_init。这告诉编译器它不需要在初始化例程中包含这些变量。例如,对于初始值不增加任何值的 RTOS 堆栈或通信缓冲区,它可能很有用。

举个例子:

__no_init int8_t timerStack[TIMER_STACK_SIZE];
__no_init int8_t displayStack[DISPLAY_STACK_SIZE];
于 2013-07-29T13:50:09.877 回答