Watchdog timeout calculation

cancel
Showing results for 
Search instead for 
Did you mean: 

Watchdog timeout calculation

Jump to solution
423 Views
Oleksii
Contributor I

I`m a newbie. Working with MK20DN512VLK10. Please, advice the formula for the watchdog timeout calculation. If possible, to have seconds. Plan to use LPO clock.

Thank you very much. My first project.

0 Kudos
1 Solution
396 Views
mjbcswitzerland
Specialist V

Hi

There is a 3 bit pre-scaler which defaults to 4 (divide by 5) and so the time is correct without needing to also adjust this when the 5 is taken into account.

mjbcswitzerland_0-1606255566267.png

Notice that the macro sets the most significant half word of the compare register to 0 since it already works for up to 320s and greater values would only be of use when the bus clock were used instead. Typically a couple seconds are used for the watchdog timeout.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

View solution in original post

0 Kudos
5 Replies
415 Views
Oleksii
Contributor I

Hi Mark, thank you very much for the reply. Can I ask you to clarify why do we need devision by 5 in WDOG_TOVALL = (time * 1000/5).
Just want to be fully aware of the logic.


Thank you.

0 Kudos
418 Views
mjbcswitzerland
Specialist V

Hi

For your device and the watchdog clocked from LPO:

// Watchdog enable and configure macro
//
#define ENABLE_WATCHDOG_TIMEOUT_SECONDS(time)  \
UNLOCK_WDOG();\
WDOG_TOVALL = (time * 1000/5);\
WDOG_TOVALH = 0;\
WDOG_STCTRLH = (WDOG_STCTRLH_STNDBYEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_WDOGEN)

 

In code use this for 1 second timeout

ENABLE_WATCHDOG_TIMEOUT_SECONDS(1); // watchdog enabled to generate reset on 1s timeout (no further updates allowed)

 

From open source uTasker project with Kinetis simulation - for faster learning and faster developments at https://github.com/uTasker/uTasker-Kinetis

 

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

0 Kudos
411 Views
Oleksii
Contributor I

Hi Mark, thank you very much for the reply.

 

Can I ask you to clarify why do we need devision by 5 in WDOG_TOVALL = (time * 1000/5).

Just want to be fully aware of the logic.


Thank you.

0 Kudos
397 Views
mjbcswitzerland
Specialist V

Hi

There is a 3 bit pre-scaler which defaults to 4 (divide by 5) and so the time is correct without needing to also adjust this when the 5 is taken into account.

mjbcswitzerland_0-1606255566267.png

Notice that the macro sets the most significant half word of the compare register to 0 since it already works for up to 320s and greater values would only be of use when the bus clock were used instead. Typically a couple seconds are used for the watchdog timeout.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

View solution in original post

0 Kudos
393 Views
Oleksii
Contributor I

Thank you very much for the detailed explanation.

0 Kudos