Secondary WatchDig Timer (SWDT)

Hi Every one
What his wrong with this

Thank’s

Marcus
//////////////////////////////////////////////////////////////////////////

#class auto

//Prototype
void Timer();

int count;

void main(void)

{
printf("begin test
");

count = 0;

// Det PB.2 has an output
WrPortI(PBDDR, &PBDDRShadow, 4);

SetVectIntern(0x01,Timer);//Below

printf("Starting SWDT
");

// init timer at 313 + 12 us tick timer interrupt
WrPortI(SWDTR, NULL, 10);

// hit crash here
WrPortI(WDTCR, NULL, 0x5F); // <<< hit crash here

printf("SWDT is running
");

while(1)
{
if (count == 3)
{
count = 0; // reset count

// Toggle PB.2 each 1ms BitWrPortI(PBDR,&PBDRShadow,!BitRdPortI(PBDR,2),2);
}
}
}

#asm
Timer::
push af
push hl

; determine why the interrupt occurred and take appropriate action

ld hl, (count)
inc hl ; increment counter
ld (count), hl

ld a, 10 ; timeout period of 11/32kHz = 331us
ioi ld (SWDTR), a ; clear the interrupt request

pop hl
pop af

ipres
ret
#endasm

What version of Dynamic C are you using?
What errors are you getting?
what are you trying to do?

What version of Dynamic C are you using?
>10.72

What errors are you getting?
>Nothing that I can see
>I can compile and run the firmware
>and it freeze when the SWDT is enabled

what are you trying to do?
>I try to use the secondary WatchDog Timer

Take a look in the source code. it’s nicely documented

Best regards,

Marcus

I ran this on an RCM6600 and it also crashed. I changed your line:
WrPortI(WDTCR, NULL, 0x5F); // <<< hit crash here
to
WrPortI(WDTCR, NULL, 0x5A);

and it appears to work

I am curious if the code change fixed your issue?