【问题标题】:My embedded application never finishes init to get to main() due to watchdog (IAR/MSP430)由于看门狗(IAR/MSP430),我的嵌入式应用程序从未完成初始化以进入 main()
【发布时间】:2013-07-28 04:05:50
【问题描述】:

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

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

【问题讨论】:

    标签: c embedded startup msp430 iar


    【解决方案1】:

    刚发完这篇,我就找到了这个应用笔记

    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;
    

    【讨论】:

    • 我最终添加了#include &lt;msp430.h&gt;,因为其他选项导致了一些链接器问题。我认为只需要定义 WDTCTL、WDTPW 和 WDTHOLD 的值。
    【解决方案2】:

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

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

    举个例子:

    __no_init int8_t timerStack[TIMER_STACK_SIZE];
    __no_init int8_t displayStack[DISPLAY_STACK_SIZE];
    

    【讨论】:

      猜你喜欢
      • 2020-11-11
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-13
      • 1970-01-01
      相关资源
      最近更新 更多