在MSP430编程过程中遇到这样一个问题:程序中数组较多,用IAR仿真时好像程序自动开始运行了,而且程序一直在执行固定的几条语句。造成这种现象的原因是程序开始执行时需要初始化全局变量,全局数组过多导致初始化时间过长引起看门狗溢出。解决这个问题有两种方法。
1、https://www.iar.com/support/tech-notes/general/my-msp430-does-not-start-up/
Introduction
This Technical Note discusses cases where an MSP430 device does not start, or does not reach the main function.
Some different symptoms
The hardware never starts up.
The MSP430 device resets without reaching the "main()" function.
The watchdog timer times out during initialization.
The cause
If the application has much (over 4k) of global initialized data, then the initialization within cstartup will not be finished before the watchdog times out (and the device is reset).
Affected derivatives
The MSP430 derivatives MSP430F1610, F1611 and F1612 have large RAM, but this Technical Note applies to any device with large RAM.
The solution
The Watchdog timer must be turned off before the initialization phase. This should preferably be done in __low_level_init.
Steps (for MSP430F1610, 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>
- Finally you should consider (if needed) where in your application the Watchdog should be activated. In such a case add the appropriate C source at that place.
2、将大数组放在RAM的不初始化区域
既然已经知道是初始化时间过长导致这个问题,我们可以把大数组定义在RAM的不初始化区域就行了。
在IAR编译器中,在定义变量之前,加上__no_initm命令即可,如__no_init char a; 即把a这个字符型变量放在RAM的不初始化区域。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。