这里写目录标题
一、用keil软件生成在proteus中可执行的文件(.hex)二、proteus的电路仿真
一、用keil软件生成在proteus中可执行的文件(.hex)
(1)新建工程 左侧选中AT89C51
(2)写入下列代码并生成main.c文件
#include
<reg51
.h
>
#define uchar unsigned char
sbit p1_0
=p1
^0;
void delay()
{
int i
, j
;
for(i
=0;i
<500;i
++)
for(j
=0;j
<500;j
++);
}
main()
{
int i
,j
;
ucharcode tab
[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,ox90
,0x88,0x83,0xc6,0xa1,0x86,0x8e};
while(1)
{
for(i
=0,i
<=15,i
++)
{
p1
=tab(1);
delay();
}
}
(3)生成hex文件 进入设置界面,在device中选中AT89C51。 在target界面选中Use on-chip ROM
在output界面选中create HEX file
二、proteus的电路仿真
将生成的HEX可执行文件放入51单片机中,然后仿真结果如下: