|
在网上找了一下ds1302的相关程序,自己仿照写的一些程序,在LCD1602上面显示了日期时间
附上仿真图
- //这个是main.c
- #include <reg52.h>
- #include "lcd1602.h"
- #include "ds1302.h"
- void Delay(unsigned int count)
- {
- unsigned int i,j;
- for(i=0;i<count;i++)
- for(j=0;j<120;j++);
- }
- main()
- {
- SYSTEMTIME CurrentTime;//现在时间
- lcd_init();
- Initial_DS1302();
-
- while(1)
- {
- DS1302_GetTime(&CurrentTime);
- TimeToStr(&CurrentTime);
- GotoXY(6,1);
- Print(CurrentTime.TimeString);
- DateToStr(&CurrentTime);
- GotoXY(4,0);
- Print(CurrentTime.DateString);
- Delay(400);
- }
-
- }
复制代码
|
|