#include<iom128v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
uchar tt;
#pragma interrupt_handler timer1_ovf_isr:15
void timer1_ovf_isr()
{
tt++;
TCNT1H=0XCF; //赋初值定义0.1s
TCNT1L=0X2B;
if(tt==20) //2s时回零
tt=0;
if(tt<=10)
PORTE=0XFF;
else
PORTE=0X00;
}
void init_timer1()
{
TCCR1B=0X03; //64分频
TIFR=0X01;
TIMSK=0X04;
TCNT1H=0XCF;
TCNT1L=0X2B;
SREG|=BIT(7);
}
void main()
{
DDRE=0XFF;
PORTE=0X00;
init_timer1();
while(1);
}
|