Arduino 的时钟(毫秒)是否在中断期间继续在后台计数? [英] Does Arduino's clock (millis) continue counting in the background during interrupts?

查看:33
本文介绍了Arduino 的时钟(毫秒)是否在中断期间继续在后台计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题,从我读过的内容来看,显然没有在网上说:我知道 Arduino 上的 millis() 在自定义中断期间不会改变,但是 相关的计时器是否仍然计数背景?

I have a quick question which apparently isn't said online from what I've read: I know millis() on an Arduino doesn't change during a custom interrupt, but does the associated timer still counts in the background?

我的程序对时间敏感,我想知道我是否应该在每次处理一个中断时增加它的值(如何?),以便主程序的时钟不会漂移.

My program is time-sensitive and I would like to know if I should increase its value (how?) each time one of my interrupts is handled so that the main program's clock doesn't drift.

提前致谢,问候,神秘先生

Thanks in advance, Regards, Mister Mystère

推荐答案

即使中断被禁用,CPU 内部计时器也会计数.但是 当定时器溢出时会产生一个中断,这将增加库中的一些计数器.如果那个中断被阻塞了很长时间......那么你就会有一个漂移.

The CPU-internal timer will count even when interrupts are disabled. BUT when the timer overflows an interrupt is generated which will increment some counter in the library. If that interrupt is blocked for a long time ... then you will have a drift.

这篇关于Arduino 的时钟(毫秒)是否在中断期间继续在后台计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆