1602显示万年历.docVIP

  • 3
  • 0
  • 约8.64千字
  • 约 10页
  • 2018-12-21 发布于河北
  • 举报
1602显示万年历

#includereg52.h //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义 #include intrins.h sbit SCK=P2^7; //时钟 sbit SDA=P2^6; //数据 sbit RST = P2^5;// DS1302复位 sbit RS = P2^0; //定义端口 sbit RW = P2^1; sbit EN = P2^2; #define RS_CLR RS=0 #define RS_SET RS=1 #define RW_CLR RW=0 #define RW_SET RW=1 #define EN_CLR EN=0 #define EN_SET EN=1 #define DataPort P0 bit ReadRTC_Flag;//定义读DS1302标志 unsigned char l_tmpdate[7]={59,42,22,22,1,2,13};//秒分时日月周年 unsigned char l_tmpdisplay[18]; code unsigned char write_rtc_address[7]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c}; //秒分时日月周年 最低位读写位 code unsigned char read_rtc_address[7]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d}; //读的地址 /******************************************************************/ /* 函数声明 */ /******************************************************************/ void Write_Ds1302_byte(unsigned char temp); void Write_Ds1302( unsigned char address,unsigned char dat ); unsigned char Read_Ds1302 ( unsigned char address ); void Read_RTC(void);//read RTC void Set_RTC(void); //set RTC void InitTIMER0(void);//inital timer0 /*------------------------------------------------ uS延时函数,含有输入参数 unsigned char t,无返回值 unsigned char 是定义无符号字符变量,其值的范围是 0~255 这里使用晶振12M,精确延时请使用汇编,大致延时 长度如下 T=tx2+5 uS ------------------------------------------------*/ void DelayUs2x(unsigned char t) { while(--t); } /*------------------------------------------------ mS延时函数,含有输入参数 unsigned char t,无返回值 unsigned char 是定义无符号字符变量,其值的范围是 0~255 这里使用晶振12M,精确延时请使用汇编 ------------------------------------------------*/ void DelayMs(unsigned char t) { while(t--) { //大致延时1mS DelayUs2x(245); DelayUs2x(245); } } /*------------------------------------------------ 判忙函数 ------------------------------------------------*/ bit LCD_Check_Busy(void) { DataPort= 0xFF; RS_CLR; RW_SET; EN_CLR; _nop_(); EN_SET; return (bit)(DataPort 0x80); } /*-------------------------------------------

文档评论(0)

1亿VIP精品文档

相关文档