以AT89C51单片机为核心制作一个LCD显示的智Word文档下载推荐.docx
- 文档编号:20909156
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:17
- 大小:91.15KB
以AT89C51单片机为核心制作一个LCD显示的智Word文档下载推荐.docx
《以AT89C51单片机为核心制作一个LCD显示的智Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《以AT89C51单片机为核心制作一个LCD显示的智Word文档下载推荐.docx(17页珍藏版)》请在冰豆网上搜索。
(5)宽范围工作电压2.0-5.5V。
(6)工作电流为2.0A时,小于300nA。
(7)功耗很低,保持数据和时钟信息时功率小于1mW。
6.2方案论证
6.3系统硬件电路的设计
……
6.4系统程序的设计
write_com_date(0xc7,0x30+minute%10);
write_com_date(0xc6,0x30+minute/10);
hour=read1302(0x85);
write_com_date(0xc4,0x30+hour%10);
write_com_date(0xc3,0x30+hour/10);
day=read1302(0x87);
write_com_date(0x8a,0x30+day%10);
write_com_date(0x89,0x30+day/10);
week=read1302(0x8b);
write_com_date(0xcd,0x30+week%10);
month=read1302(0x89);
write_com_date(0x87,0x30+month%10);
write_com_date(0x86,0x30+month/10);
year=read1302(0x8d);
write_com_date(0x84,0x30+year%10);
write_com_date(0x83,0x30+year/10);
}
voidkeyscan()//修改调整时间日期
{
if(key1==0)
{
delay(10);
pos_flag++;
while(!
key1);
keyflag=1;
switch(pos_flag)
case1:
write_com(0x80+4);
//年
write_com(0x0f);
//光标闪烁
break;
case2:
write_com(0x80+7);
//月
case3:
write_com(0x80+10);
//日
case4:
write_com(0x80+0x40+0x0d);
//星期
case5:
write_com(0x80+0x40+4);
//时钟
case6:
write_com(0x80+0x40+7);
//分钟
case7:
write_com(0x80+0x40+10);
//秒钟
default:
break;
}
if(pos_flag==8)//pos_flag=8则退出调整
pos_flag=0;
keyflag=0;
//按键标识清零
delay(5);
settime();
write_com(0x0c);
//关光标
if(key2==0)//调节加键,按下(低电平)就加
delay(15);
if(key2==0)
while(!
key2);
switch(pos_flag)
year++;
if(year==99)
year=0;
write_com_date(0x84,0x30+year%10);
month++;
if(month==13)
month=1;
write_com_date(0x87,0x30+month%10);
day++;
if((year%4==0)&
&
(month==2))//闰年二月29天
{
if(day==30)
day=1;
}
if((year%4!
=0)&
(month==2))//平年二月28天
if(day==29)
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)//大月31天
if(day==32)
day=1;
}
if(month==4||month==6||month==9||month==11)//小月30天
if(day==31)
write_com_date(0x8a,0x30+day%10);
week++;
if(week==8)
week=1;
write_com_date(0xcd,0x30+week);
hour++;
if(hour==24)
hour=0;
write_com_date(0xc4,0x30+hour%10);
minute++;
if(minute==60)
minute=0;
write_com_date(0xc7,0x30+minute%10);
second++;
if(second==60)
second=0;
write_com_date(0xca,0x30+second%10);
write_com_date(0xc9,0x30+second/10);
if(key3==0)
key3);
year--;
if(year==0)
year=99;
month--;
if(month==0)
month=12;
day--;
if(day==0)
day=29;
day=28;
if(day==0)
day=31;
day=30;
week--;
if(week==0)
week=7;
hour--;
if(hour==0)
hour=24;
minute--;
if(minute==0)
minute=59;
second--;
if(second==0)
second=59;
}
voidmain()
init_lcd();
delay
(2);
init_ds1302();
Disp_1602(1,0,"
20--week"
);
Disp_1602(5,1,"
:
:
"
while
(1)
if(keyflag==0)
display();
keyscan();
#ifndef_lcd_h_
#define_lcd_h_
#include<
reg51.h>
#defineucharunsignedchar
#defineuintunsignedint
sbitlcdrs=P2^0;
sbitlcdrw=P2^1;
sbitlcden=P2^2;
voiddelay(ucharms)
uchari;
for(;
ms>
0;
ms--)
for(i=110;
i>
i--);
voidwrite_com(ucharcom)//写指令
lcden=0;
lcdrs=0;
lcdrw=0;
P0=com;
delay
(1);
lcden=1;
voidwrite_data(uchardate)//写数据
lcdrs=1;
P0=date;
voidwrite_com_date(ucharadd,uchardate)
write_com(add);
write_data(date);
voidDisp_1602(ucharx,uchary,uchar*p)
while(*p)
if(y==0)x|=0x80;
elsex|=0xc0;
write_com(x);
delay(5);
write_data(*p);
x++;
p++;
voidinit_lcd()
delay(15);
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
#endif
#ifndef_ds1302_h_
#define_ds1302_h_
sbitsclk=P1^1;
sbitio=P1^0;
sbitrst=P1^2;
sbitACC_7=ACC^7;
voidwrite1302(ucharadd,uchardate)//写入地址、数据
rst=0;
sclk=0;
rst=1;
for(i=0;
i<
8;
i++)
io=add&
0x01;
add>
>
=1;
sclk=1;
io=date&
date>
ucharread1302(ucharadd)//读地址、数据
uchari,dat1,dat2;
sclk=0;
{
ACC_7=io;
ACC>
dat1=ACC;
dat2=dat1/16;
dat1=dat1%16;
dat1=dat2*10+dat1;
returndat1;
voidinit_ds1302()
if(((read1302(0x81))&
0x0f)==1)
write1302(0x8e,0x00);
//关闭写保护
#endif……
6.5调试及性能分析
6.5.1调试与测试
6.5.2性能分析
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- AT89C51 单片机 核心 制作 一个 LCD 显示