#include<iomacro.h>
#include<iom16.h>
//#include <iom48a.h>
#include <intrinsics.h>
#define uchar unsigned char
int time0_counter=0;
void main(void)
{
__disable_interrupt();
TCCR0 = 0x00; //stop
//SREG=0x00;
TIMSK|=0x01; //使能T0溢出中断
TCCR0=0x01; //配置定时器工作普通模式
TCNT0=0x5e;
// TCCR0=0x05;
// TIMSK=0x01;
//SREG_I=1;
__enable_interrupt();
while(1)
{
;
}
}
#pragma vector = TIMER0_OVF_vect
__interrupt void timer0_ovf_isr(void)
{
uchar temp;
temp=SREG;
TCNT0=0x5e;
time0_counter++;
SREG=temp;
} |