AnsweredAssumed Answered

Watchdog enables itself after reset

Question asked by Abdullah Kahraman on Jun 21, 2013
Latest reply on Jun 25, 2013 by Abdullah Kahraman

I am using TWR-S08DC-PT60 board which has a MC9S08PT60 microcontroller.

 

I am trying to disable the watchdog timer in my application. After configuring it in the software, it is disabled in the first run after programming, as wanted. However, after a reset occurs, either by reset button or power down, it is automatically enabled by itself. This happens when I debug, run or flash using CodeWarrior 10.4. Here is how I disable it:

 

  _WDOG_CS1.Bits.UPDATE = 1; // Enable changes to WDOG.   WDOG_CNT = 0xC520; // write the 1st unlock word   WDOG_CNT = 0xD928; // write the 2nd unlock word    _WDOG_CS1.Bits.EN = 0; // Kill the dog.   _WDOG_CS1.Bits.INT = 1; // Enable WDOG interrupt. 

 

When I debug the application, I can see that UPDATE bit is set and the watchdog timer is disabled, also, it behaves as desired when I reset using the debugger. However, in case of a reset by the reset button or power down, watchdog timer is enabled again and reset the MCU, since I do not feed it in the main loop. Also, it doesn't create an interrupt before resetting the MCU, although its interrupt is enabled. I can see, by the help of SYS_SRS (system reset source) register that the MCU is last reset by watchdog timer. Commenting out 2nd and 3rd line (WDOG_CNT=...) does not help.

 

Here is my full code:

main.c

init.h

init.c

 

(Links are to pastebin.com online source code sharing service.)

Outcomes