文件仅供参考:
链接:https://pan.baidu.com/s/1yUigOtG7_7a2sxrYD_KB-Q
提取码:tviy
硬件设计
功能:
1、8位数码管显示当前时间。
2、使用DS1302获得时钟信号,能够进行时钟设置
3、能够设置10组打铃时间,并具有临时打铃功能,打铃的时长为5S钟
4、使用1602液晶屏幕显示。
仿真图:
程序设计
#include <all.h>
u8 LCD1602_Cursor_address=0; //光标标记
// uchar code degree[]={
0x16,0x09,0x08,0x08,0x08,0x09,0x06,0x00}; //摄氏度 符号
bit lcd_busy_test(void) //忙状态监测
{
bit result;
RS=0;
RW=1;
EN=1;
_nop_();
_nop_();
_nop_();
_nop_();
result = (bit)(DB&0x80);
EN=0;
return result;
}
void lcd_write_cmd (u8 cmd) //写命令
{
while (lcd_busy_test());
RS=0;
RW=0;
EN=0;
_nop_();
_nop_();
DB=cmd ;
_nop_();
_nop_();
_nop_();
_nop_();
EN=1;
_nop_();
_nop_();
_nop_();
_nop_();
EN=0;
}
void lcd_position (u8 pos)//显示起始位置
{
if(pos<16)
lcd_write_cmd (pos|0x80);
else
lcd_write_cmd (((pos)-16)|0xC0);
}
void lcd_write_data (u8 dat)//写数据
{
while (lcd_busy_test());
RS=1;
RW