Show you my code, just for reference.
#include <REGX52.H>
#include <INTRINS.H>
void Delay200ms(); //The function is generated by STC_ISP.
int main()
{
unsigned char i;
while(1)
{
for(i=0;i<=7;i++)
{
P1=_crol_(0xfe,i);
Delay200ms();
}
for(i=0;i<=7;i++)
{
P1=_cror_(0x7f,i);
Delay200ms();
}
}
return 0;
}
void Delay200ms() //@12.000MHz
{
unsigned char i, j, k;
_nop_();
i = 2;
j = 134;
k = 20;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
} |