#include<reg52.h>
sbit ENLED = P1^4;
sbit ADDR3 = P1^3;
sbit ADDR2 = P1^2;
sbit ADDR1 = P1^1;
sbit ADDR0 = P1^0;
void shiftleft(unsigned char *p);
void main()
{
unsigned int i=0;
unsigned char buf=0x01;
TMOD = 0X01;
TH0 = 0XFC;
TL0 = 0X67;
TR0 = 1;
ENLED = 0;
ADDR3 = 1;
ADDR0 = 0;
ADDR1 = 1;
ADDR2 = 1;
while(1)
{
P0=~buf;
for(i=0;i<40000;i++);
while(1)
{
if(TF0 ==1)
{
TF0 = 0;
TH0 = 0XFC;
TL0 = 0X67;
i++;
if(i==1000)
{
i=0;
}
break;
shiftleft(&buf);
}
}
if(buf == 0)
{
buf= 0x01;
}
}
}
void shiftleft(unsigned char *p)
{
*p = *p <<1;
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我刚开始接触这个 有点不太明白 还望大神指导
while(1)弄好了
{
P0=~buf;
if(TF0 ==1)
{
TF0 = 0;
TH0 = 0XFC;
TL0 = 0X67;
i++;
if(i==1000)
{
i=0;
shiftleft(&buf);
}
}
if(buf == 0)
{
buf= 0x01;
}
}
}
void shiftleft(unsigned char *p)
{
*p = (*p) <<1;
}
一周热门 更多>