AnsweredAssumed Answered

Watchdog on MC9S08PT16

Question asked by dunghoangvan on May 29, 2017

Hi all,

 

I am testing Watchdog on mc9s08pt16, but it does not work.

 

Details source code as below:

 

#define wdog_unlock() asm(LDA #0xC5); asm(STA 0x3032); asm(LDA #0x20);asm(STA 0x3033);\
asm(LDA #0xD9); asm(STA 0x3032); asm(LDA #0x28); asm(STA 0x3033)

 

void wdog_enable(void )
{
DisableInterrupts;
wdog_unlock();

WDOG_CNT = 0xC520u;

WDOG_CNT = 0xD928u;
WDOG_WIN = 0x00u; /* Setup window register high */
WDOG_TOVAL = 0xF0u; /* Setup time-out value register high */

/* WDOG_CS1: EN=1,INT=0,UPDATE=1,TST=0,DBG=1,WAIT=1,STOP=1 */

WDOG_CS1 = 0xA7u; // 10100111

/* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=2 */

WDOG_CS2 = 0x2u; /* 32 kHz internal oscillator (ICSIRCLK)*/

EnableInterrupts;
}

 

 

 

Main:

 

void main(void) {
EnableInterrupts;
wdog_enable(); // init Wdog
for (;;) {
__RESET_WATCHDOG(); /* feeds the dog */

for (;;) {
}


//__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
}

 

Looking forward to your support.

 

Thanks.

Original Attachment has been moved to: Innit-Wdog.c.zip

Original Attachment has been moved to: main.c.zip

Outcomes