c51单片机怎样利用中断程序写一
#include
unsigned int LED;
unsigned int a,i,m;
void yiwei();
void delay(unsigned int b);
void main()
{
TMOD=0x01; //T0为方式1
TH0=(65536-50000)/256;
TL0=(65536-50000)%256; //初值
EA=1; //允许中断
ET0=1;
while(1)
{
P2=0x00;
delay(2000);
LED = 0x7f;
m=0;
for (i = 0 ;i >1; // 右移
LED = LED|0x80;
}
el...全部
#include
unsigned int LED;
unsigned int a,i,m;
void yiwei();
void delay(unsigned int b);
void main()
{
TMOD=0x01; //T0为方式1
TH0=(65536-50000)/256;
TL0=(65536-50000)%256; //初值
EA=1; //允许中断
ET0=1;
while(1)
{
P2=0x00;
delay(2000);
LED = 0x7f;
m=0;
for (i = 0 ;i >1; // 右移
LED = LED|0x80;
}
else
{
P2 = LED;
LED = LED 0; b--) //机器在这里执行需要一段时间 也就达到了延时效果
for(j = 255; j > 0; j--);
}
自己调试过,我12晶振。
收起