本文重点:C52流水灯代码编写,keil如何生存hex文件和proteus如何导入hex文件。
1、打开keil,建立工程,编写如下代码。
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay(uint z);
void main()
{
temp=0xfe;
P1=temp;
while(1)
{
temp=_crol_(temp,1);
delay(600);
P1=temp;
}
}
void delay(uint z)
{
uint x,y;
for(x=100;x>0;x--)
for(y=z;y>0;y--);
}
2、代码写完后,点击Rebuild all target files。
3、点击Options for target,选择Output,勾上Create HEX File,创建hex文件。
4、再次点击Rebuild all target files控件,编译生成hex文件。
5、打开proteus,点击Iisis。
6、点击AT89C52,添加hex文件
7、运行和停止