历史上的今天
今天是:2024年10月14日(星期一)
2019年10月14日 | LCD1602&DS1302时钟测试程序+仿真图分享
2019-10-14 来源:eefocus
comments :
1、八线制驱动LCD1602B:PB0-PB7为数据线,PD3/PD4/PD6控制LCD1602B的RS,RW,EN。
2、设置和读取DS1302内部时钟,并通过LCD1602显示。
3、进行此实验请插上JP1、JP2的所有8个短路块,PC2、PC3、PC4、PC7短路块。
4、DS1302芯片接口占用JTAG仿真接口,在做实验时需要关闭mega16的JTAG功能,否则
不正常显示。
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
#include #include #include "ds1302.h" #include "LCD1602.h" void main(void) { unsigned char temp; Port_init(); //端口初始化 LCD_init(); //LCD初始化 LCD_clear(); //清屏 ds1302_init(); //DS1302初始化 delay_ms(10); ds1302_write_time(); //写入初始值 while (1) { delay_ms(200); //每200ms更新一次时间 ds1302_read_time(); //读取时间 //LCD_clear(); //清屏 temp = (time_buf[0] >> 4) + '0'; LCD_write_char(0, 0, temp);/*年*/ temp = (time_buf[0] & 0x0F) + '0'; LCD_write_char(1, 0, temp); temp = (time_buf[1] >> 4) + '0'; LCD_write_char(2, 0, temp); temp = (time_buf[1] & 0x0F) + '0'; LCD_write_char(3, 0, temp); LCD_write_char(4, 0, '-'); temp = (time_buf[2] >> 4) + '0'; LCD_write_char(5, 0, temp);/*月*/ temp = (time_buf[2] & 0x0F) + '0'; LCD_write_char(6, 0, temp); LCD_write_char(7, 0, '-'); temp = (time_buf[3] >> 4) + '0'; LCD_write_char(8, 0, temp);/*日*/ temp = (time_buf[3] & 0x0F) + '0'; LCD_write_char(9, 0, temp); LCD_write_str(0,1,"week:"); temp = (time_buf[7]) + '0'; LCD_write_char(5, 1, temp); //周 temp = (time_buf[4] >> 4) + '0'; LCD_write_char(8, 1, temp); //时 temp = (time_buf[4] & 0x0F) + '0'; LCD_write_char(9, 1, temp); LCD_write_char(10, 1, ':'); temp = (time_buf[5] >> 4) + '0'; LCD_write_char(11, 1, temp);/*分*/ temp = (time_buf[5] & 0x0F) + '0'; LCD_write_char(12, 1, temp); LCD_write_char(13, 1, ':'); temp = (time_buf[6] >> 4) + '0'; LCD_write_char(14, 1, temp);/*秒*/ temp = (time_buf[6] & 0x0F) + '0'; LCD_write_char(15, 1, temp); } }
史海拾趣
|
本帖最后由 jameswangsynnex 于 2015-3-3 20:00 编辑 由于数字技术与传统的模拟技术相比在很多方面都具有明显的优势,所以正如数字技术在许多领域取代了模拟技术一样,光端机的数字化也是一种必然趋势。目前,数字光端机主要有两种技术方式:一种 ...… 查看全部问答> |
|
今天无意间看到一个好东东,眼前一亮啊! 来看看他的鸡鸡呀。。德国鬼子的电子管机器。用的全是猛料呀。15斤的硬木箱子清一色铜镀铬箱子配件(包角合页和锁扣)箱子看着像是红木的。原装东西没动过的!通电正常,整机耀耀生辉的古董。用了一共大小 ...… 查看全部问答> |
|
我往S3C2440上移植ucGUI,做了一次Hello,World的小测试,结果Hello,world可以显示,但是现实的却是有俩个,本来应该在左上显示,但现在是左上也有,左下三分之二屏那也有,很奇怪,不知道哪些地方有问题,望高手解答!!!… 查看全部问答> |
|
调用CreatFile函数后,如何根据其返回值判断设备当前的状态呢? 我在做一个关于USB通信的程序,现在要求在没有装驱动或者设备没有插好的情况下,在上位机的程序中给出提示,该怎么实现,请高手指教。能不能通过调用CreatFile函数后再用GetLastError函数得到错误代码来进行区分呢,我试过,好象错误代 ...… 查看全部问答> |
|
请教: 帮我看看这几个问题啊 1: 波特率发生器 是什么啊, 是不是 T0 ,T1 啊 2: 定时器预置数 这里计算出来的是 FA 是 TH1 = FA; TL1 = FA; 还是 TH1 = 0; TL1 = FA; 还是 TL1 = FA TH1 = 0; 谢谢! 3: T1 ...… 查看全部问答> |




