#include<iom16v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
#pragma interrupt_handler timer1:9
uchar i,temp;
void delay(uint x)
{
uint y,z;
for(y=x;y>0;y--)
for(z=1111;z>0;z--);
}
void main(void)
{
i=0;
temp=0x01;
TCCR1B=0x04; //T/C1时钟源,256分频
TCNT1H=0x85; //赋初值,外部晶振8M,定时1s
TCNT1L=0xed;
TIMSK=0x04; //开T/C1中断
SREG=0x80;
DDRB=0xff;
while(1);
}
void timer1(void)
{
TCNT1H=0x85;
TCNT1L=0xed;
if(i<8)
{
PORTB=temp;
temp<<=1;
i++;
}
else
{
i=0;
temp=0x01;
}
}