#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
uint temp,i,cishu;
void delay(uint);
void main()
{
temp=0xfe;
P1=temp;
cishu=0; //为次数 赋值0
while(cishu<2) // 规定流水灯来回循环2次
{
cishu++; //每一次循环 次数 +1
for(i=7;i>0;i--) { temp=_crol_(temp,1); delay(300); P1=temp; } //左移
for(i=7;i>0;i--) { temp=_cror_(temp,1); delay(300); P1=temp; } //右移
}
delay(300);
temp=0xff; //两次循环结束后 跳出while,执行此处的 P1口全部灭
P1=temp;
}
void delay(uint z)
{
uint x,y;
for(x=100;x>0;x--)
for(y=z;y>0;y--);
}
出现的问题是 LED 灯一直来回的循环不停止了。。。 我用while(cishu<2) 来限制程序执行的次数 但是 好像这个while(cishu<2) 并没有 作用 请问这程序错在哪了?