|
这是我做的一个51中断入门的小例子,包括proteusl仿真图,供大家体验中断的使用
#include<reg51.h>
sbit P26=P2^6;
unsigned int n=0;
void timer0(void)interrupt 1 using 1
{
TH0=0Xff;
TL0=0Xfc;
P2=~P2;
}
void main()
{
TMOD=0X01;
TH0=0Xff;
TL0=0Xfc;
EA=1;
ET0=1;
TR0=1;
P2=0;
here:
goto here;
}
|
|