单片机==ds1302_时间日期周几(30)

本文详细介绍了如何使用单片机配合DS1302芯片设置和显示时间、日期以及星期的功能,包括通信协议和编程实现步骤。
摘要由CSDN通过智能技术生成
#include <reg52.h>
#include "delay.h"

#define ds1302_sec_add          0x80        //??¨ºy?Y¦Ì??¡¤
#define ds1302_min_add          0x82        //¡¤?¨ºy?Y¦Ì??¡¤
#define ds1302_hr_add           0x84        //¨º¡À¨ºy?Y¦Ì??¡¤
#define ds1302_date_add         0x86        //¨¨?¨ºy?Y¦Ì??¡¤
#define ds1302_month_add        0x88        //??¨ºy?Y¦Ì??¡¤
#define ds1302_day_add          0x8a        //D??¨²¨ºy?Y¦Ì??¡¤
#define ds1302_year_add         0x8c        //?¨º¨ºy?Y¦Ì??¡¤
#define ds1302_control_add      0x8e        //????¨ºy?Y¦Ì??¡¤
#define ds1302_charger_add      0x90                     
#define ds1302_clkburst_add     0xbe

sbit RST = P1^0;
sbit SCK = P1^1;
sbit IO = P1^2;

unsigned char w_tbuf = 3;
unsigned char writeweek = 0;
unsigned char readweek = 0;
unsigned char disweek = 0;

unsigned char tempbuf[3];
unsigned char readbuf[3];
unsigned char disbuf[3];
unsigned char writebuf[3];
unsigned char w_dbuf[3];
unsigned char r_dbuf[3];
unsigned char d_dbuf[3];

unsigned char datebuf[3] = {
  16,8,17};
unsigned char timebuf[3] = {
  16,01,35};

//unsigned char weekbuf[7] = {MON,TUE,WED,THU,FRI,SAT,SUN};


#define LCDPORT P0
sbit RS = P2^4;
sbit RW = P2^5;
sbit E = P2^6;

#define LCD_WRITE_DATA 1
#define LCD_WRITE_COM 0

void lcd_write(unsigned char byte, unsigned char flag)
{
    if(flag)
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值