cancel
Showing results for 
Search instead for 
Did you mean: 

Watchdog strange behavior

rickard
Associate II
Posted on April 09, 2008 at 10:06

Watchdog strange behavior

5 REPLIES 5
rickard
Associate II
Posted on May 17, 2011 at 09:51

The Watchdog seems to behave a bit strange.

I trigger the Watchdog in a while-loop like:

while(timerExpired == false)

{

TrigWD();

}

TrigWD()

{

WDG->KR = 0xA55A;

WDG->KR = 0x5AA5;

}

In this case the cpu will sometimes crash, even though WD is triggered all the time.

If I change the code to:

TrigWD()

{

WDG_Cmd(ENABLE);

}

The cpu will also crash

I tried to change the code to not trigger the watchdog all the time:

TrigWD()

{

if(WDG->CNT < 0x76) // preload value is 83

{

WDG->KR = 0xA55A;

WDG->KR = 0x5AA5;

}

}

It still crashes....

But if I change the function to

TrigWD()

{

if(WDG->CNT < 0x76)

{

WDG_Cmd(ENABLE);

}

}

It will work fine. Is there a problem when triggering the WatchDog to often? Have anyone seen this? Is it a silicon limitation?

I am running the cpu at 94,5 MHz and using RTC clock for WD. The compiler is GCC.

mark9
Associate II
Posted on May 17, 2011 at 09:51

Try (as an experiment) to run the watchdog from the PCLK instead of RTC. I had a similar problem with the watchdog on RTC. The problem was that if there was a WD reset, the WD would continue to be enabled *after* the reset, so it would immediately have another WD reset. This was extremely repeatable.

Mark

amira1
Associate II
Posted on May 17, 2011 at 09:51

Hello rickard.thorstensson, lakata,

This problem is never seen before. I tried to use the WDG reset with the RTC as clock source and fCPU=96MHz. However, I didn't see any crash.

Could you please send me a simple code where you can reproduce this problem.

Thank you in advance and best regards,

mirou.

[ This message was edited by: mirou on 08-04-2008 10:22 ]

rickard
Associate II
Posted on May 17, 2011 at 09:51

[This post handled another problem, removed]

[ This message was edited by: rickard.thorstensson on 09-04-2008 13:59 ]

rickard
Associate II
Posted on May 17, 2011 at 09:51

Ignore my previous post, it was another problem. The real problem seems to be that the compiler don't store the registers r0,r1,r2,r3 in functions before modifying them, causing a instable behaviour. The code worked when I changed the timing since no damage was caused by the register change.

I.e. the compiler should do like this

void Function()

{

stmdb sp!, {r0,r1,r2,r3, lr}

mov r0, #256 ; 0x100

mov r1, #1 ; 0x1

...

if r0 to r3 are used in the function.

but it doesn't do that, it do like this:

void Function()

{

mov r0, #256 ; 0x100

mov r1, #1 ; 0x1

Is there any configuration to tell the compiler to store r0 to r3 also? Why does the compiler behave like this? Is it a bug?

I'm using GnuArm 4.1

[ This message was edited by: rickard.thorstensson on 09-04-2008 13:58 ]