4
votes

I am coding a simple game and trying to test it on an MSP430F5529 microcontroller. The problem I have encountered is relating to the watchdog timer.

The code I have written causes a device reset, which is an indication of a watchdog timer issue. I assume I need to stop it even before the first line of my main code, some sort of pre-initialisation code. Am I on the right track by sayin that or may the problem lie some other sections of the code as well?

To make it more clear, my main code is as follows (in simple form):

  1. Stop the watchdog timer.
  2. Initialize the board (GPIO pins).
  3. Set up the Vcore voltage for CPU.
  4. Set up the reference crystal (XTAL).
  5. Set up the system clock.
  6. Enable interrupts (globally).
  7. Set up real time clock (RTC).
  8. Set up LCD display.
  9. Initialize the buttons.
  10. Wait in an appropriate LPM mode for the user input.

As far as I am concerned, this sequence of code should be right.

1

1 Answers

6
votes

Here are some thoughts. You must explicitly disable the watchdog if you do not plan on feeding it. You shouldn't have to do this in the pre-init code (unless you personally modified the pre-init code and made it longer to execute). Doing it at the beginning of main should be OK barring the following case. There's the possibility that having static arrays may force them to be initialized to zero in the pre-init code. If they are large, that could take some time, maybe enough to have the watchdog trigger before getting out of the pre-init code. Also, on at least some MSP430s, you must unlock the Clock registers with a password before writing to them. If you don't, the chip will reset.

Here is a link discussing watchdog in pre-init code if you haven't seen it already: http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/267695.aspx