#include#include unsigned char num[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//0-9 unsigned char num2[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//0.--9. unsigned char wirte_address[7]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};//写寄存器的地址 unsigned char read_address[7] ={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};//读寄存器的地址 unsigned char time[7]={0x50,0x55,0x14,0x05,0x06,0x07,0x22}; //以16进制的形式直接存放在数组中,显示的时候直接除于16即可 //秒 分 时 日 月 周 年 void HC573(unsigned char n) { switch(n) { case 4: P2=(P2 & 0x1f) | 0x80;break; case 5: P2=(P2 & 0x1f) | 0xa0;break; case 6: P2=(P2 & 0x1f) | 0xc0;break; case 7: P2=(P2 & 0x1f) | 0xe0;break; } } void Initsystem() { HC573(5); P0=0x00; HC573(4); P0=0xff; } void Delay(unsigned int t) { while(t--); } void SMG_Show(unsigned char dat,unsigned char pos) { HC573(6); P0=0x01< 底层驱动代码
#ifndef __DS1302_H #define __DS1302_H #include#include sbit SCK = P1^7; sbit SDA = P2^3; sbit RST = P1^3; void Write_Ds1302(unsigned char temp);//写字节 void Write_Ds1302_Byte( unsigned char address,unsigned char dat );//向DS1302寄存器写入数据 unsigned char Read_Ds1302_Byte( unsigned char address );//从DS1302寄存器读出数据 #endif



