cancel
Showing results for 
Search instead for 
Did you mean: 

WD activation problem in AK_ST7FMC

jermakov
Associate II
Posted on July 05, 2007 at 06:06

WD activation problem in AK_ST7FMC

4 REPLIES 4
jermakov
Associate II
Posted on July 02, 2007 at 09:04

Hello All and Gigi,

May you help me to solve problem with WD, detailed descibed below?

Thank you,

Alexander, jermakov#taide.lt

=================================================================

Bug report

Header: WWDG failed refreshing

Input data:

HW: AK_ST7FMC Starter Kit (based on ST7FMC2N6)

SW: BLDC_3PH_SR_2.0

How to observe:

- found and uncomment in the module main.c the following lines:

// while ( !WWD_Init() );

…

// if (Chk_Timer_WDG_Elapsed() == TRUE) WWD_Refresh();

- check in MCU option bytes the setting:

WDG activation: by SW

- recompile the application and run it;

- found RESET is generating every 128 ms.

Description:

The WD main procedures are here:

#define WDG_TIMEOUT 80

Void WWD_Init(void)

{

WWDGCR = WDGA + 0x7F; // Starts the Window watchdog and load it to its max value

WWDGWR = 0x5B; // Refresh window is between 72 and 128ms (100ms+/-28ms)

Timer_WDG = WDG_TIMEOUT;

return(TRUE);

}

void WWD_Refresh(void)

{

WWDGCR = WDGA + 0x7F; // Reload Window watchdog with max value

Timer_WDG = WDG_TIMEOUT;

}

And WD refreshing is done within main program loop and controlled by Timer_WDG:

if (Chk_Timer_WDG_Elapsed() == TRUE) WWD_Refresh();

Timer_WDG is completely working, as all other program timers andit was checked separately. While WD disabled, Timer_WDG is going, but since WD enabled, there no WD refresh is acting, and seems the timer to be stopped.

I have tried to variate WDG _TIMEOUT, WWDGWR and WWDGCR setting, but I have not got refreshing at any case.

Question:

How to adjust WD and timer setting in order to get correct refreshing?

==================================================================

wolfgang2399
Associate II
Posted on July 03, 2007 at 07:29

Hi Alexander,

first additional questions:

- what do you do with Chk_Timer_WDG_Elapsed() ?

- how do you define WDGA ?

- what does your compiler with a return value in a void function - void WWD_Init(void) - ?

Finally an idea:

If you call WWD_Init() cyclically, you'll get a forced reset because of:

see chapter 10.1 WINDOW WATCHDOG (WWDG)

 

- 10.1.3 Functional Description

 

... If the software reloads the counter

 

while the counter is greater than the value stored

 

in the window register, then a reset is generated.

Regards,

WoRo

jermakov
Associate II
Posted on July 04, 2007 at 17:28

Hello WoRo,

Thank you for the quick replay.

>- what do you do with Chk_Timer_WDG_Elapsed() ?

Nothing special. This function is very easy :

BOOL Chk_Timer_WDG_Elapsed(void)

{

if (Timer_WDG == 0) return(TRUE);

else return(FALSE);

}

?- how do you define WDGA ?

This bit is defined in the module ST7MC_hr.h like:

#define WDGA ((u8)0x80)

>- what does your compiler with a return value in a void function - void WWD_Init(void) - ?

Hmm, I am very sorry. This is just stupid mistake. Sure, in the source BLDC_3PH_SR_2.0 this function is declared as BOOL :

Void WWD_Init(void)

{

WWDGCR = WDGA + 0x7F; // Starts the Window watchdog and load it to its max value

WWDGWR = 0x5B; // Refresh window is between 72 and 128ms (100ms+/-28ms)

Timer_WDG = WDG_TIMEOUT;

return(TRUE);

}

>Finally an idea:

If you call WWD_Init() cyclically, you'll get a forced reset because of:

Yes, you are right! At this case I would get very fast resetting with no delay. But in fact I have got periodical reset each 128ms, so while free-running WD counter gets overloaded.

If I do direct WD refreshing within main program loop (without checking of the Chk_Timer_WDG_Elapsed), then I got forced reset every 10 ms (because main loop is fast and WD refreshing goes before window timeout).

But once the Chk_Timer_WDG_Elapsed was taken in adeal, than I got no WD refreshing and caused 128ms period resetting.

My problem is that like Timer B interrupts stops working, once WD activated.

Is there any influence of WD to the timer B interrupts?

Regards,

Alexander.

wolfgang2399
Associate II
Posted on July 05, 2007 at 06:06

Hi Alexander,

please give me more information about how you handle the Timer_WDG and where you take the clock for this timer.

I suppose the cause of your problem in mismatching of Timer_WDG.

Best regards

WoRo