#include<mega8.h>
#define uchar unsigned char
#define uint unsigned int
#define SEI SREG|=0x80
#define LED PORTC.3
void IO_Init(void)
{
DDRC.3=1;
LED="1";
DDRD.4=0;
PORTD.4=1;
}
void Timer0_Init(void)
{
TCCR0=0;
TCNT0=254;
TIMSK|=0x01;
SEI;
TCCR0=0x06;
}
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
TCNT0=254;
LED=!LED; //按下按钮两次,灯更换一次状态
}
void main(void)
{
IO_Init();
Timer0_Init();
while(1){;;}
}
文章评论(0条评论)
登录后参与讨论