熟悉Proteus 8 电路仿真软件,完成一个51程序设计和仿真
新建Proteus 8 工程
完成一个51程序设计和仿真 ,时钟信号和在规定时间时响铃
电路仿真图片:
keil编译图片:
代码:
char i,j,a,b,c,d,e,f
;
uchar code table0
[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
};
sbit P10
=P1^0
;
sbit P17
=P1^7
;
sbit P20
=P2^0
;
sbit P21
=P2^1
;
sbit P22
=P2^2
;
sbit P23
=P2^3
;
sbit P24
=P2^4
;
sbit P25
=P2^5
;
timer0
() interrupt 1 using 1
{
P10
=!P10
;
TH0
=-50000/256
;
TL0
=-50000%256
;
}
timer1
() interrupt 3 using 2
{
P17
=!P17
;
i++
;
if
(i
==10
)
{
j++
;
P20
=1
;
if
(j
==6
){j
=0
;c++
;}
P0
=table0
[j
];
P20
=0
;
}
if
(c
>0
)
{
P21
=1
;
if
(c
==10
){c
=0
;d++
;}
P0
=table0
[c
];
P21
=0
;
}
if
(d
>0
)
{
P22
=1
;
if
(d
==6
){b
=0
;e++
;}
P0
=table0
[d
];
P22
=0
;
}
if
(e
>0
)
{
P23
=1
;
if
(e
==10
){e
=0
;f++
;}
P0
=table0
[e
];
P23
=0
;
}
if
(f
>0
)
{
P24
=1
;
if
(f
==2
&&e
==4
){f
=0
;e
=0
;}
P0
=table0
[f
];
P24
=0
;
}
P20
=0
;
if
(i
==10
)i
=0
;
P0
=table0
[i
];
if
(f
==0
&&e
==8
&&b
==0
&&c
==0
){P25
=1
;}
if
(f
==0
&&e
==8
&&b
==0
&&c
==1
){P25
=0
;}
if
(f
==0
&&e
==8
&&b
==4
&&c
==5
){P25
=1
;}
if
(f
==0
&&e
==8
&&b
==4
&&c
==6
){P25
=0
;}
if
(f
==0
&&e
==8
&&b
==5
&&c
==5
){P25
=1
;}
if
(f
==0
&&e
==8
&&b
==5
&&c
==6
){P25
=0
;}
if
(f
==0
&&e
==9
&&b
==4
&&c
==0
){P25
=1
;}
if
(f
==0
&&e
==9
&&b
==4
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==0
&&b
==1
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==0
&&b
==1
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==0
&&b
==5
&&c
==5
){P25
=1
;}
if
(f
==1
&&e
==0
&&b
==5
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==1
&&b
==0
&&c
==5
){P25
=1
;}
if
(f
==1
&&e
==1
&&b
==0
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==1
&&b
==5
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==1
&&b
==5
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==4
&&b
==0
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==4
&&b
==0
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==4
&&b
==4
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==4
&&b
==4
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==4
&&b
==5
&&c
==5
){P25
=1
;}
if
(f
==1
&&e
==4
&&b
==5
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==5
&&b
==4
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==5
&&b
==4
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==6
&&b
==1
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==6
&&b
==1
&&c
==1
){P25
=0
;}
if
(f
==1
&&e
==6
&&b
==5
&&c
==5
){P25
=1
;}
if
(f
==1
&&e
==6
&&b
==5
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==7
&&b
==0
&&c
==5
){P25
=1
;}
if
(f
==1
&&e
==7
&&b
==0
&&c
==6
){P25
=0
;}
if
(f
==1
&&e
==7
&&b
==5
&&c
==0
){P25
=1
;}
if
(f
==1
&&e
==7
&&b
==5
&&c
==1
){P25
=0
;}
}
main
()
{
P20
=1
;P21
=1
;P22
=1
;P23
=1
;P24
=1
;P25
=0
;
P0
=table0
[0
];
P20
=0
;P21
=0
;P22
=0
;P23
=0
;P24
=0
;
P17
=0
;
P10
=1
;
TMOD
=0x61
;
TH0
=-50000/256
;
TL0
=-50000%256
;
TH1
=-5
;
TL1
=-5
;
IP
=0X08
;
EA
=1
;ET0
=1
;ET1
=1
;
TR0
=1
;TR1
=1
;
for
(;;);
}
keil和proteus 8 仿真的步骤
第一步:右击Target 1,选择Options for Target 第二步:勾上Creat HEX File 第三步:选择Proteus VSM Simulator 第四步:右击c51,选择编辑属性 第五步:从Clock Frequency 中选择keil编译的hex文件,最后进行仿真
总结:
不懂的可以上网找,网上的资料真的多。