看门狗定时器
有什么办法可以编写类似于WDT的代码吗?如果您有任何建议或源代码,我们将不胜感激。我没有找到合适的解决方案。
我在网上得到的答案几乎都是针对特定芯片组的。但我需要类似于 WDT 类型的实现。众所周知,WDT 是一个计数器,从某个初始值向下计数到零。在达到最小值之前,程序必须做出响应,否则会触发中断。
int counter = reset_counter();
while(counter!=0) {
// mode = return value of function which is boolean.
if (mode) {
// check return if true reset counter
reset_counter();
}
counter--;
}
我不知道我的代码是否可以正常工作! 我想使用的语言是 C/C++。
Is there any way I can write code similar to WDT? If you have any suggestions or src code is much appreciated.I am not finding proper solution.
Answers I got on web are almost for specific chipsets. But I need similar to WDT kind of implementation. As we all know WDT is a counter that counts down from some initial value to zero. Before it hits minimum value program has to respond else a interrupt is fired.
int counter = reset_counter();
while(counter!=0) {
// mode = return value of function which is boolean.
if (mode) {
// check return if true reset counter
reset_counter();
}
counter--;
}
I dont know whether my code works properly!
Language I would like to use is C/C++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在嵌入式系统上工作吗?为什么不使用计时器?通常他们会计算……但这并不重要。最后它在溢出时创建一个中断。
要确定您的代码是否正常工作,您必须自己进行测试。
Are you wokring on an embedded system? Why not use a timer? Usually they count up ... but that doesn't matter. In the end it creates an interrupt on overflow.
To find out if your code works correctly you have to test it yourself.