LCD1602液晶显示DS1302实时时钟Proteus仿真

上传人:suij****uang 文档编号:119684678 上传时间:2022-07-15 格式:DOCX 页数:5 大小:98.58KB
返回 下载 相关 举报
LCD1602液晶显示DS1302实时时钟Proteus仿真_第1页
第1页 / 共5页
LCD1602液晶显示DS1302实时时钟Proteus仿真_第2页
第2页 / 共5页
LCD1602液晶显示DS1302实时时钟Proteus仿真_第3页
第3页 / 共5页
亲,该文档总共5页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Proteus仿真图: LCD! Lh/blELI/OSCLKRST:1VCC2VCC1JXTAL1PO.OfADDP0.KAD1P0.2fAD2XTAL2P0.3fAD3PO.4fAC4P0.5fAD5po.erADBRSTP0.7iAD7P2 0/A8P2.1/A9P2.2/A10PSENP2.3/AT1ALEP2.4/A12EAP2.5/A13P2.6/A14P2.7/A15P1 .DP3.0JRXDPI .1P3.1 iTXDPI .2P3.2JINT0PI .3P3.3JINT1P1.4P3.4.-TDPI .5P3.5JTIPI .BP3.6JWRP1 7F37.iRD仿真程序:#include#include#include#define uint unsigned int#define uchar unsigned char/*LCD*sbit LCDRS=P2A0;/LCD数据/命令选择端sbit LCDRW=P2A1;sbit LCDEN=P2A2;/LCD使能新号端/*DS1302*sbit IO=P1A0;/1302数据线sbit SCLK=P1A1;sbit RST=P1A2;/1302时钟线复位uint num=0;/uchar *week=SUN,*,MON,TUS,WEN,THU,FRI,SAT;uchar Date=Date: 2000-00-00 ;uchar Time=Time: *00:00-00* ;uchar date_time7;/从ds1302读取的当前日期时间/=延时= void delay(uint z)uint x,y;for(x=z;x0;x-)for(y=110;y0;y-);*向 1302 写数据*void write_ds1302(uchar dat)uchar i;for(i=0;i= 1;/*从 1302 读数据*uchar read_ds1302()uchar i,b=0x00;for(i=0;i8;i+)b 1= _crol_(uchar)IO,i);SCLK=1;delay(1);SCLK=0;return b/16*10+b%16;*从指定位置读数据*uchar read_data(uchar addr)uchar dat;RST=0;SCLK=0;RST=1;write_ds1302(addr);dat=read_ds1302();SCLK=1;RST=0;return dat;/*读取当前日期时间*void read_date_time()uchar i,addr=0x81;for(i=0;i7;i+)date_timei=read_data(addr);addr+=2;/与BCD码转换LCD写指令void lcd_write_com(uchar com)LCDRS=0;/RS为0时,写指令,RS为1时,P0=com;delay(5);写数据LCDEN=1;delay(5);LCDEN=0;/LCD写数据void lcd_write_data(uchar dat) LCDRS=1; P0=dat; delay(5); LCDEN=1; delay(5); LCDEN=0; /LCD初始化/LCD显示模式设置/LCD显示开/关及光标设置当写一个字符后地址指针加1,且光标显示清屏void lcd_init() LCDEN=0; lcd_write_com(0x38); lcd_write_com(0x0c); lcd_write_com(0x06);加1 lcd_write_com(0x01);/设置液晶显示位置void set_lcd_pos(uchar p)lcd_write_com(p | 0x80);/液晶显示程序void lcd_print(uchar p,uchar *s) set_lcd_pos(p);for(num=0;num16;num+) lcd_write_data(snum);delay(10);/日期时间转换void format_datetime(uchar d,uchar *p)p0=d/10+0;p1=d%10+0;/主程序void main()LCDRW=0;lcd_init();while(1)read_date_time();format_datetime(date_time6,Date+8);/年月日format_datetime(date_time4,Date+11);format_datetime(date_time3,Date+14);/ strcpy(Date+13,weekdate_time5);format_datetime(date_time2,Time+7);时间转换format_datetime(date_time1,Time+10);format_datetime(date_time0,Time+13);lcd_print(0x00,Date);lcd_print(0x40,Time);
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 活动策划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!