Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm using an MSP430 chip with 10K of RAM. If I go above 5k of RAM usage, it's never capable of making it to main(). The init code calls __data20_memzero to clear out the used RAM space.

__data20_memzero source

It look like it increments through memory and clears bytes till R14=R12. R14 is 0x34B4. But the max value of R12 is 0x2c86 before it reboots and starts over again. I manually turned off the watchdog through the debugger, and it started running just fine. I can't see this as being normal. Any idea how to get around this problem?

like image 556
reza Avatar asked Jul 28 '13 07:07

reza


1 Answers

Just after posting this, I found this application note

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

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).

and

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;
like image 115
reza Avatar answered Oct 20 '22 02:10

reza