Keil软件编写程序:
特殊功能寄存器声明:
#include<reg52.h>sbit LED = P1^0;void main()
{LED = 0;while(1);
}
代码说明:
sbit 语句是特殊功能位声明。
生成HEX文件,这个文件是下载到单片机里的文件。Options for Target 'Target 1'。
程序下载:
#include<reg52.h>sbit LED = P0^0;
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;void main()
{unsigned int i = 0;ENLED = 0;ADDR3 = 1;ADDR2 = 1;ADDR1 = 1;ADDR0 = 0;while(1){LED = 0;for(i=0;i<30000;i++);LED = 1;for(i=0;i<30000;i++);}
}
LED灯的闪烁。