簡體   English   中英

由於看門狗(IAR / MSP430),我的嵌入式應用程序永遠不會完成init到main()

[英]My embedded application never finishes init to get to main() due to watchdog (IAR/MSP430)

我正在使用帶有10K RAM的MSP430芯片。 如果我超過5k的RAM使用量,它永遠不能進入main()。 init代碼調用__data20_memzero來清除已用RAM空間。

__data20_memzero來源

它看起來像是通過內存遞增並清除字節直到R14 = R12。 R14是0x34B4。 但是在重新啟動並重新開始之前,R12的最大值為0x2c86。 我通過調試器手動關閉了看門狗,它開始運行就好了。 我不能認為這是正常的。 知道如何解決這個問題嗎?

發布之后,我發現了這個應用筆記

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;

正如您所發現的,根本問題是初始化全局內存只需要太長時間。 雖然在啟動時禁用看門狗確實可以解決問題,但如果您擔心WD被關閉(甚至是暫時關閉),可能存在縮短初始化時間的替代方案。

IAR支持擴展__no_init 這告訴編譯器它不需要在初始化例程中包含這些變量。 它對於例如初始值不添加任何值的RTOS堆棧或通信緩沖區非常有用。

舉個例子:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM