#pragma sfr
#define uchar unsigned char
#define uint unsigned int
void delaynms(uint n)
{
unsigned char i;
while( n-- )
{
for(i=0;i<125;i++);
}
}
void main()
{
IMS = 0xc8; /*fast RAM 1024byte,32kbROM*/
IXS = 0x0c;
OSCCTL = 0X41; /*时钟操作模式选择寄存器*/
PCC = 0x00; /*处理器时钟控制寄存器*/
MOC = 0X00; /*主OSC控制寄存器,0=startX1,1=stop*/
MCM = 0X05; /*主时钟模式寄存器*/
PM6 = 0xf0;
P6 = 0xff;
while(1)
{
uchar i;
uchar val;
val = 0x01;
for(i=0;i<4;i++)
{
delaynms(1000);
P6 = ~val;
val = val<<1;
delaynms(1000);
}
for(i=0;i<2;i++)
{
P6 = 0xfc;
delaynms(1000);
P6 = 0xf3;
delaynms(1000);
}
for(i=0;i<2;i++)
{
P6=0xff;
delaynms(1000);
P6=0xf0;
delaynms(1000);
}
}
}
文章评论(0条评论)
登录后参与讨论