#pragma sfr
#define uchar unsigned char
#define uint unsigned int
void delaynms(uint n)
{
uint i,j;
for(i=n;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
IMS = 0xc8;
IXS = 0x0c;
OSCCTL = 0X41;
PCC = 0x00;
MOC = 0X00;
MCM = 0X05;
for(;;)
{
uchar temp = 0x01;
uchar i;
PM6 = 0xf0;
P6 = 0xfe;
delaynms(500);
for(i = 3;i >0;i --)
{
temp <<= 1;
P6 = ~temp;
delaynms(500);
}
}
}
delaynms是利用sm+仿真出来的,大约1ms