极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 16594|回复: 4

Arduino中该怎样实现定时器功能?

[复制链接]
发表于 2012-4-13 09:05:41 | 显示全部楼层 |阅读模式
如题,谢谢~
回复

使用道具 举报

发表于 2012-4-13 09:52:43 | 显示全部楼层
可以参考下官方的资料http://www.arduino.cc/playground/code/timer1
回复 支持 反对

使用道具 举报

发表于 2012-5-19 10:47:37 | 显示全部楼层
楼主 说出了我的心声啊,我找了好久没找到定时器,还以为 arduino 木有 !!原来要自己下啊。。
回复 支持 反对

使用道具 举报

发表于 2013-7-28 20:17:13 | 显示全部楼层
请问弘毅高手,下面的代码中定时器0多久中断一次!?这个代码是核心代码定时器0

#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
SIGNAL(TIM0_OVF_vect)
#else
SIGNAL(TIMER0_OVF_vect).
#endif
{
        // copy these to local variables so they can be stored in registers
        // (volatile variables must be read from memory on every access)

        unsigned long m = timer0_millis;
        unsigned char f = timer0_fract;

        m += MILLIS_INC;   
        f += FRACT_INC;   
        if (f >= FRACT_MAX) {
                f -= FRACT_MAX;
                m += 1;
        }

        timer0_fract = f;
        timer0_millis = m;
        timer0_overflow_count++;
}
回复 支持 反对

使用道具 举报

发表于 2014-11-23 11:18:38 | 显示全部楼层
弘毅 发表于 2012-4-13 09:52
可以参考下官方的资料http://www.arduino.cc/playground/code/timer1

没有中文的吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-19 13:13 , Processed in 0.040749 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表