Watchdog timeout calculation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Watchdog timeout calculation

跳至解决方案
3,053 次查看
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 项奖励
回复
1 解答
3,026 次查看
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

 

在原帖中查看解决方案

0 项奖励
回复
5 回复数
3,045 次查看
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 项奖励
回复
3,048 次查看
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 项奖励
回复
3,041 次查看
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 项奖励
回复
3,027 次查看
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

 

0 项奖励
回复
3,023 次查看
Oleksii
Contributor I

Thank you very much for the detailed explanation.

0 项奖励
回复