KE1 WDOG Prescaler Inaccuracies with LPO Clock

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

KE1 WDOG Prescaler Inaccuracies with LPO Clock

跳至解决方案
192 次查看
sean_dvorscak
Contributor III

I am trying to run WDOG with a 20ms timeout.

I've configured the WDOG_CS for LPO clock source (128kHz) and PRES = 1, and WDOG_TOVAL = 0x000A.

That should be 10/(128,000/256) = 10/500 = 0.02s.

However, I started noticing some inconsistencies that led me to believe I am overrunning the 20ms in my SW, but the WDOG wasn't resetting me. I then instrumented my code to Set/Clear a GPIO pin to see how much time was elapsing before I refreshed the WDOG, and saw 20.67ms from refresh to refresh.

I was curious to see how long the WDOG timeout is actually set for, so I then added some dummy delays just after refreshing the WDOG that would just wait for the WDOG to reset. The Oscope showed 24ms from refresh to timeout.

I then confirmed using the CLKOUT pin that the LPO clock was indeed running at 128kHz.

Frustrated, I then switched my clock source to the SIRC and adjusted the TOVAL = 625 (625/[8MHz/256] = 625/31250 = 0.02s). Running the same test as before, I saw 20ms on the dot.

I got confused so I then reverted back to the LPO clock, but removed the prescaler. I was concerned that the low frequency was causing some sort of error. When reverting back to the LPO clock without prescaler, and setting TOVAL = 2560 (2560/128000 = 0.02s), I started to see 20ms timeouts from the WDOG.

My question is why did I see such a huge accuracy hit when using the prescaler with the LPO clock? I didn't see the accuracy hit with the SIRC using prescaler. Is there a known error when it comes to this configuration? Frequency too low?

Very confused.

0 项奖励
回复
1 解答
131 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @sean_dvorscak 

Your theoretical calculation is correct: with a 128 kHz LPO clock and WDOG_CS[PRES] = 1 , the WDOG clock becomes 500 Hz. Therefore, with TOVAL = 10 , the theoretical timeout is 20 ms.

However, in this configuration, the counter tick is 2 ms, and TOVAL = 10 is a very small count value. Any internal synchronization, configuration update, or refresh-path latency can therefore be magnified into millisecond-level timing differences.  Therefore, we do not recommend using LPO + ÷256 with such a small TOVAL value to implement an accurate 20 ms watchdog timeout.

If a 20 ms timeout is required, we recommend using the LPO without the prescaler and setting TOVAL = 2560 , or using the 8 MHz SIRC with ÷256 and setting TOVAL = 625 .

If the software refresh interval may reach 20.67 ms, we also recommend increasing the watchdog timeout to provide sufficient design margin.

Hope it helps.

 

Thank you.

 

BR

Alice

在原帖中查看解决方案

0 项奖励
回复
2 回复数
132 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @sean_dvorscak 

Your theoretical calculation is correct: with a 128 kHz LPO clock and WDOG_CS[PRES] = 1 , the WDOG clock becomes 500 Hz. Therefore, with TOVAL = 10 , the theoretical timeout is 20 ms.

However, in this configuration, the counter tick is 2 ms, and TOVAL = 10 is a very small count value. Any internal synchronization, configuration update, or refresh-path latency can therefore be magnified into millisecond-level timing differences.  Therefore, we do not recommend using LPO + ÷256 with such a small TOVAL value to implement an accurate 20 ms watchdog timeout.

If a 20 ms timeout is required, we recommend using the LPO without the prescaler and setting TOVAL = 2560 , or using the 8 MHz SIRC with ÷256 and setting TOVAL = 625 .

If the software refresh interval may reach 20.67 ms, we also recommend increasing the watchdog timeout to provide sufficient design margin.

Hope it helps.

 

Thank you.

 

BR

Alice

0 项奖励
回复
55 次查看
sean_dvorscak
Contributor III

Thanks for the clarification. I had a feeling it had something to do with the low frequency. Interesting to know that the low TOVAL is also part of the issue.

I already fixed this to use the LPO clock without the prescaler and TOVAL of 2560 as you suggested. Also added an extra WDOG refresh during this one time extended process that was overrunning the WDOG timeout.

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2387876%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EKE1%20WDOG%20%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E5%9C%A8%E4%BD%BF%E7%94%A8%20LPO%20%E6%97%B6%E9%92%9F%E6%97%B6%E5%87%BA%E7%8E%B0%E8%AF%AF%E5%B7%AE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2387876%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%9D%E8%AF%95%E8%BF%90%E8%A1%8C%20WDOG%EF%BC%8C%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%E4%B8%BA%2020%20%E6%AF%AB%E7%A7%92%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%B7%B2%E7%BB%8F%E5%B0%86%20WDOG_CS%20%E9%85%8D%E7%BD%AE%E4%B8%BA%20LPO%20%E6%97%B6%E9%92%9F%E6%BA%90%20(128kHz)%20%E5%92%8C%20PRES%20%3D%201%EF%BC%8CWDOG_TOVAL%20%3D%200x000A%E3%80%82%3C%2FP%3E%3CP%3E%E9%82%A3%E5%BA%94%E8%AF%A5%E6%98%AF%2010%2F(128%2C000%2F256)%20%3D%2010%2F500%20%3D%200.02%20%E7%A7%92%E3%80%82%3C%2FP%3E%3CP%3E%E7%84%B6%E8%80%8C%EF%BC%8C%E6%88%91%E5%BC%80%E5%A7%8B%E6%B3%A8%E6%84%8F%E5%88%B0%E4%B8%80%E4%BA%9B%E4%B8%8D%E4%B8%80%E8%87%B4%E4%B9%8B%E5%A4%84%EF%BC%8C%E8%BF%99%E8%AE%A9%E6%88%91%E7%9B%B8%E4%BF%A1%E6%88%91%E7%9A%84%E8%BD%AF%E4%BB%B6%E8%BF%90%E8%A1%8C%E6%97%B6%E9%97%B4%E8%B6%85%E8%BF%87%E4%BA%86%2020%20%E6%AF%AB%E7%A7%92%EF%BC%8C%E4%BD%86%20WDOG%20%E5%B9%B6%E6%B2%A1%E6%9C%89%20RESET%20%E6%88%91%E3%80%82%E7%84%B6%E5%90%8E%EF%BC%8C%E6%88%91%E4%BF%AE%E6%94%B9%E4%BA%86%E6%88%91%E7%9A%84%E4%BB%A3%E7%A0%81%EF%BC%8C%E4%BD%BF%E5%85%B6%E8%83%BD%E5%A4%9F%E8%AE%BE%E7%BD%AE%2F%E6%B8%85%E9%99%A4%E4%B8%80%E4%B8%AA%20GPIO%20%E5%BC%95%E8%84%9A%EF%BC%8C%E4%BB%A5%E6%9F%A5%E7%9C%8B%E5%9C%A8%E5%88%B7%E6%96%B0%20WDOG%20%E4%B9%8B%E5%89%8D%E7%BB%8F%E8%BF%87%E4%BA%86%E5%A4%9A%E9%95%BF%E6%97%B6%E9%97%B4%EF%BC%8C%E7%BB%93%E6%9E%9C%E5%8F%91%E7%8E%B0%E4%BB%8E%E5%88%B7%E6%96%B0%E5%88%B0%E5%88%B7%E6%96%B0%E4%B9%8B%E9%97%B4%E6%9C%89%2020.67%20%E6%AF%AB%E7%A7%92%E7%9A%84%E6%97%B6%E9%97%B4%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%BE%88%E5%A5%BD%E5%A5%87%20WDOG%20%E8%B6%85%E6%97%B6%E5%AE%9E%E9%99%85%E8%AE%BE%E7%BD%AE%E4%BA%86%E5%A4%9A%E9%95%BF%E6%97%B6%E9%97%B4%EF%BC%8C%E6%89%80%E4%BB%A5%E6%88%91%E5%9C%A8%E5%88%B7%E6%96%B0%20WDOG%20%E5%90%8E%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%B8%80%E4%BA%9B%E8%99%9A%E6%8B%9F%E5%BB%B6%E8%BF%9F%EF%BC%8C%E7%AD%89%E5%BE%85%20WDOG%20RESET%E3%80%82%E7%A4%BA%E6%B3%A2%E5%99%A8%E6%98%BE%E7%A4%BA%E4%BB%8E%E5%88%B7%E6%96%B0%E5%88%B0%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%E4%B8%BA%2024%20%E6%AF%AB%E7%A7%92%E3%80%82%3C%2FP%3E%3CP%3E%E7%84%B6%E5%90%8E%E6%88%91%E4%BD%BF%E7%94%A8%20CLKOUT%20%E5%BC%95%E8%84%9A%E7%A1%AE%E8%AE%A4%20LPO%20%E6%97%B6%E9%92%9F%E7%A1%AE%E5%AE%9E%E4%BB%A5%20128kHz%20%E7%9A%84%E9%A2%91%E7%8E%87%E8%BF%90%E8%A1%8C%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E6%84%9F%E5%88%B0%E5%BE%88%E6%B2%AE%E4%B8%A7%EF%BC%8C%E4%BA%8E%E6%98%AF%E5%B0%86%E6%97%B6%E9%92%9F%E6%BA%90%E5%88%87%E6%8D%A2%E5%88%B0%20SIRC%EF%BC%8C%E5%B9%B6%E5%B0%86%20TOVAL%20%E8%B0%83%E6%95%B4%E4%B8%BA%20625%EF%BC%88625%2F%5B8MHz%2F256%5D%20%3D%20625%2F31250%20%3D%200.02s%EF%BC%89%E3%80%82%E8%BF%90%E8%A1%8C%E4%B8%8E%E4%B9%8B%E5%89%8D%E7%9B%B8%E5%90%8C%E7%9A%84%E6%B5%8B%E8%AF%95%EF%BC%8C%E6%88%91%E7%9C%8B%E5%88%B0%E7%BB%93%E6%9E%9C%E6%AD%A3%E5%A5%BD%E6%98%AF%2020%20%E6%AF%AB%E7%A7%92%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%BD%93%E6%97%B6%E6%9C%89%E7%82%B9%E7%B3%8A%E6%B6%82%E4%BA%86%EF%BC%8C%E6%89%80%E4%BB%A5%E5%8F%88%E6%94%B9%E5%9B%9E%E4%BA%86%20LPO%20%E6%97%B6%E9%92%9F%EF%BC%8C%E4%BD%86%E6%98%AF%E7%A7%BB%E9%99%A4%E4%BA%86%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E3%80%82%E6%88%91%E6%8B%85%E5%BF%83%E4%BD%8E%E9%A2%91%E7%8E%87%E4%BC%9A%E5%AF%BC%E8%87%B4%E6%9F%90%E7%A7%8D%E9%94%99%E8%AF%AF%E3%80%82%E5%BD%93%E6%81%A2%E5%A4%8D%E5%88%B0%E6%B2%A1%E6%9C%89%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E7%9A%84%20LPO%20%E6%97%B6%E9%92%9F%EF%BC%8C%E5%B9%B6%E5%B0%86%20TOVAL%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%202560%EF%BC%882560%2F128000%20%3D%200.02%20%E7%A7%92%EF%BC%89%E6%97%B6%EF%BC%8C%E6%88%91%E5%BC%80%E5%A7%8B%E7%9C%8B%E5%88%B0%20WDOG%20%E5%87%BA%E7%8E%B0%2020%20%E6%AF%AB%E7%A7%92%E7%9A%84%E8%B6%85%E6%97%B6%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E7%9A%84%E9%97%AE%E9%A2%98%E6%98%AF%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E4%BD%BF%E7%94%A8%20LPO%20%E6%97%B6%E9%92%9F%E7%9A%84%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E6%97%B6%EF%BC%8C%E7%B2%BE%E5%BA%A6%E4%BC%9A%E4%B8%8B%E9%99%8D%E8%BF%99%E4%B9%88%E5%A4%9A%EF%BC%9F%E6%88%91%E6%B2%A1%E6%9C%89%E5%8F%91%E7%8E%B0%E4%BD%BF%E7%94%A8%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E7%9A%84%20SIRC%20%E7%B2%BE%E5%BA%A6%E6%9C%89%E6%89%80%E4%B8%8B%E9%99%8D%E3%80%82%E8%BF%99%E7%A7%8D%E9%85%8D%E7%BD%AE%E6%98%AF%E5%90%A6%E5%AD%98%E5%9C%A8%E5%B7%B2%E7%9F%A5%E9%94%99%E8%AF%AF%EF%BC%9F%E9%A2%91%E7%8E%87%E5%A4%AA%E4%BD%8E%EF%BC%9F%3C%2FP%3E%3CP%3E%E9%9D%9E%E5%B8%B8%E5%9B%B0%E6%83%91%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2388157%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KE1%20WDOG%20Prescaler%20Inaccuracies%20with%20LPO%20Clock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2388157%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CFONT%20color%3D%22%23000000%22%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F90401%22%20target%3D%22_blank%22%3E%40sean_dvorscak%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%3CSPAN%3E%E4%BD%A0%E7%9A%84%E7%90%86%E8%AE%BA%E8%AE%A1%E7%AE%97%E6%98%AF%E6%AD%A3%E7%A1%AE%E7%9A%84%EF%BC%9A%E5%BD%93%20LPO%20%E6%97%B6%E9%92%9F%E9%A2%91%E7%8E%87%E4%B8%BA%20128%20kHz%20%E4%B8%94%20WDOG_CS%5BPRES%5D%20%3D%201%20%E6%97%B6%EF%BC%8CWDOG%20%E6%97%B6%E9%92%9F%E9%A2%91%E7%8E%87%E5%8F%98%E4%B8%BA%20500%20Hz%E3%80%82%E5%9B%A0%E6%AD%A4%EF%BC%8C%E5%BD%93%20TOVAL%20%3D%2010%20%E6%97%B6%EF%BC%8C%E7%90%86%E8%AE%BA%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%E4%B8%BA%2020%20%E6%AF%AB%E7%A7%92%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%3CSPAN%3E%20%E4%BD%86%E6%98%AF%EF%BC%8C%E5%9C%A8%E8%BF%99%E7%A7%8D%E9%85%8D%E7%BD%AE%E4%B8%8B%EF%BC%8C%E8%AE%A1%E6%95%B0%E5%99%A8%E6%BB%B4%E7%AD%94%E6%95%B0%E4%B8%BA%202%20%E6%AF%AB%E7%A7%92%EF%BC%8C%E8%80%8C%3CSTRONG%3ETOVAL%20%3D%2010%20%E6%98%AF%E4%B8%80%E4%B8%AA%E9%9D%9E%E5%B8%B8%E5%B0%8F%E7%9A%84%E8%AE%A1%E6%95%B0%E5%80%BC%3C%2FSTRONG%3E%E3%80%82%E5%9B%A0%E6%AD%A4%EF%BC%8C%E4%BB%BB%E4%BD%95%E5%86%85%E9%83%A8%E5%90%8C%E6%AD%A5%E3%80%81%E9%85%8D%E7%BD%AE%E6%9B%B4%E6%96%B0%E6%88%96%E5%88%B7%E6%96%B0%E8%B7%AF%E5%BE%84%E5%BB%B6%E8%BF%9F%E9%83%BD%E5%8F%AF%E8%83%BD%E8%A2%AB%E6%94%BE%E5%A4%A7%E5%88%B0%E6%AF%AB%E7%A7%92%E7%BA%A7%E7%9A%84%E6%97%B6%E9%97%B4%E5%B7%AE%E5%BC%82%E3%80%82%E5%9B%A0%E6%AD%A4%EF%BC%8C%E6%88%91%E4%BB%AC%E4%B8%8D%E5%BB%BA%E8%AE%AE%E4%BD%BF%E7%94%A8%20LPO%20%2B%20%C3%B7256%20%E5%92%8C%E5%A6%82%E6%AD%A4%E5%B0%8F%E7%9A%84%20TOVAL%20%E5%80%BC%E6%9D%A5%E5%AE%9E%E7%8E%B0%E7%B2%BE%E7%A1%AE%E7%9A%84%2020%20%E6%AF%AB%E7%A7%92%E7%9C%8B%E9%97%A8%E7%8B%97%E8%B6%85%E6%97%B6%E3%80%82%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%3CSPAN%3E%E5%A6%82%E6%9E%9C%E9%9C%80%E8%A6%81%2020%20%E6%AF%AB%E7%A7%92%E7%9A%84%E8%B6%85%E6%97%B6%EF%BC%8C%3CSTRONG%3E%E6%88%91%E4%BB%AC%E5%BB%BA%E8%AE%AE%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%B8%A6%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E7%9A%84%20LPO%20%E5%B9%B6%E5%B0%86%20TOVAL%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%202560%3C%2FSTRONG%3E%20%EF%BC%8C%E6%88%96%E8%80%85%E4%BD%BF%E7%94%A8%208%20MHz%20SIRC%20%E5%B9%B6%E5%B0%86%20TOVAL%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%20625%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%3CSPAN%3E%20%E5%A6%82%E6%9E%9C%E8%BD%AF%E4%BB%B6%E5%88%B7%E6%96%B0%E9%97%B4%E9%9A%94%E5%8F%AF%E8%83%BD%E8%BE%BE%E5%88%B0%2020.67%20%E6%AF%AB%E7%A7%92%EF%BC%8C%E6%88%91%E4%BB%AC%E4%B9%9F%E5%BB%BA%E8%AE%AE%E5%A2%9E%E5%8A%A0%E7%9C%8B%E9%97%A8%E7%8B%97%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%EF%BC%8C%E4%BB%A5%E6%8F%90%E4%BE%9B%E8%B6%B3%E5%A4%9F%E7%9A%84%E8%AE%BE%E8%AE%A1%E8%A3%95%E5%BA%A6%E3%80%82%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%E5%B8%8C%E6%9C%9B%E5%AF%B9%E6%82%A8%E6%9C%89%E6%89%80%E5%B8%AE%E5%8A%A9%E3%80%82%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%E8%B0%A2%E8%B0%A2%EF%BC%81%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22%22%3EBR%3C%2FP%3E%0A%3CP%20class%3D%22%22%3E%E7%88%B1%E4%B8%BD%E4%B8%9D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2389199%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20KE1%20WDOG%20Prescaler%20Inaccuracies%20with%20LPO%20Clock%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2389199%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E8%B0%A2%E8%B0%A2%E4%BD%A0%E7%9A%84%E8%A7%A3%E9%87%8A%E3%80%82%E6%88%91%E6%84%9F%E8%A7%89%E8%BF%99%E5%92%8C%E4%BD%8E%E9%A2%91%E7%8E%87%E6%9C%89%E5%85%B3%E3%80%82%E5%80%BC%E5%BE%97%E6%B3%A8%E6%84%8F%E7%9A%84%E6%98%AF%EF%BC%8C%E4%BD%8E%E6%80%BB%E4%BB%B7%E5%80%BC%E4%B9%9F%E6%98%AF%E9%97%AE%E9%A2%98%E7%9A%84%E4%B8%80%E9%83%A8%E5%88%86%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E5%B7%B2%E7%BB%8F%E6%8C%89%E7%85%A7%E6%82%A8%E7%9A%84%E5%BB%BA%E8%AE%AE%EF%BC%8C%E4%BF%AE%E5%A4%8D%E4%BA%86%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BD%BF%E7%94%A8%E6%B2%A1%E6%9C%89%E9%A2%84%E5%88%86%E9%A2%91%E5%99%A8%E7%9A%84%20LPO%20%E6%97%B6%E9%92%9F%EF%BC%8C%E5%B9%B6%E5%B0%86%20TOVAL%20%E8%AE%BE%E7%BD%AE%E4%B8%BA%202560%E3%80%82%E6%AD%A4%E5%A4%96%EF%BC%8C%E7%94%B1%E4%BA%8E%E6%AD%A4%E6%AC%A1%E5%BB%B6%E9%95%BF%E8%BF%9B%E7%A8%8B%E8%B6%85%E8%BF%87%E4%BA%86%20WDOG%20%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4%EF%BC%8C%E8%BF%98%E9%A2%9D%E5%A4%96%E6%B7%BB%E5%8A%A0%E4%BA%86%E4%B8%80%E6%AC%A1%20WDOG%20%E5%88%B7%E6%96%B0%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E