4

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.

Jon 'links in bio' Ericson
  • 20,880
  • 12
  • 98
  • 148
gbudan
  • 889
  • 7
  • 17

1 Answers1

6

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

gtozzi
  • 61
  • 2
  • Why do you suggest not to do it in the pre-init code? – gbudan May 23 '14 at 18:14
  • I didn't suggest not to do it in pre-init code; I said you should not have to. I probably shouldn't have said "shouldn't have to". That could imply changing the pre-init code to be a negative thing (which it's not as long as you know what you're doing), or that this particular case doesn't come up often (which is an assumption on my part). – gtozzi May 26 '14 at 18:50