📄 timer._c
字号:
#include <macros.h>
#include "stdtypes.h"
#include "timer.h"
UNS8 time_couter;
//TIMER0 initialize - prescale:256
// WGM: Normal
// desired value: 10mSec
// actual value: 9.984mSec (0.2%)
void timer0_init(void)
{
TCCR0 = 0x00; //stop
ASSR = 0x00; //set async mode
TCNT0 = SET_COUNT; //set count
TCCR0 = 0x07; //start timer
TIMSK = TIMSK | (1 << TOIE0);
time_couter=0;
}
#pragma interrupt_handler timer0_ovf_isr:17
void timer0_ovf_isr(void)
{
//CLI(); //disable all interrupts
TCNT0 = SET_COUNT;
/*read the key value*/
if(time_couter>10)
{
time_couter=0;
}
else
{
time_couter++;
}
// SEI(); //re-enable interrupts
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -