timer.c

来自「ATmega128芯片的测试程序」· C语言 代码 · 共 29 行

C
29
字号
#include"timer.h"
#include"mostns.h"

static unsigned int count;    //一个计数变量
extern bool MostCheckFlag;
extern word tick_count; //系统启动后到当前的运行时间
void Timer0Init()
{
	count=2000;
    TCNT0=0X8D;    //定时1ms
    TCCR0=0X04;
    TIMSK=_BV(TOIE0);
    
}

SIGNAL(SIG_OVERFLOW0)
{
    TCNT0=0X8D;
    tick_count++;
	count--;
	if(count==0)
	{
	   count=2000;
	   MostCheckFlag=TRUE;
     }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?