标题:
100000秒以内的计时单片机程序+Proteus仿真
[打印本页]
作者:
dong12
时间:
2020-5-11 10:49
标题:
100000秒以内的计时单片机程序+Proteus仿真
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
51hei.png
(14.86 KB, 下载次数: 34)
下载附件
2020-5-11 14:47 上传
单片机源程序如下:
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar Count;
sbit Dot = P0^7;
uchar code DSY_CODE[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
uchar Digits_of_6DSY[]={0,0,0,0,0,0};
void DelayMS(uint x)
{
uchar i;
while(--x)
{
for(i=0;i<120;i++);
}
}
void main()
{
uchar i,j;
P0 = 0x00;
P3 = 0xff;
Count =0;
TMOD = 0x01;
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
IE = 0x82;
TR0 = 1;
while(1)
{
j = 0x7f;
for(i=5;i!=-1;i--)
{
j=_crol_(j,1);
P3 = j;
P0 = DSY_CODE[Digits_of_6DSY[i]];
if(i==1) P0 |= 0x80;
DelayMS(2);
}
}
}
void Time0() interrupt 1
{
uchar i;
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
if(++Count !=2) return;
Count = 0;
Digits_of_6DSY[0]++;
for(i=0;i<=5;i++)
{
if(Digits_of_6DSY[i] == 10)
{
Digits_of_6DSY[i] = 0;
if(i != 5) Digits_of_6DSY[i+1]++;
}
else break;
}
}
复制代码
所有资料51hei提供下载:
100000秒以内的计时程序.zip
(50.33 KB, 下载次数: 12)
2020-5-11 10:49 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
xiaodong11
时间:
2020-5-14 11:01
不错的资料
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1