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.
Solved! Go to Solution.
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.
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
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.
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
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.
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.
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
Thank you very much for the detailed explanation.