//位操作点亮发光二极管
#include
#include
sbit D2=P1^3;
void OSCILLATOR_Init(void)
{
U8 SFRPAGE_save = SFRPAGE;
SFRPAGE = CONFIG_PAGE;
OSCICN = 0x87; // Set internal osc. divider to 1
SFRPAGE = SFRPAGE_save;
}
void PORT_Init(void)
{
U8 SFRPAGE_save = SFRPAGE;
SFRPAGE = CONFIG_PAGE;
P1MDIN |= 0x08; // P1.3 is digital
P1MDOUT = 0x08;
XBR2 = 0x40; // Enable crossbar and GLOBAL enable weak pull-ups
SFRPAGE = SFRPAGE_save;
}
/*void Delay(unsigned m)
{
char i=0;
while(–m)
{
for(i=0;i<120;i++);//修正i的最大值来调整延时时刻,延时时刻核算:
}
}*/
//延时能够运用上面的或下面的双层for循环,单层时刻太短
void delay()
{
unsigned int i;
unsigned char j;
for(i=1;i<3000;i++)
{
for(j=1;j<120;j++);
}
}
void main()
{
OSCILLATOR_Init();//时钟初始化
PORT_Init();//端口初始化
PCA0MD &= ~0x40; //制止看门狗
D2=1;
//Delay(1200);
delay();
D2=0;
delay();
//Delay(1200);
}