SPI时钟芯片DS1302的应用
//======================================驱动
sbit SDA_1302=P1^0;
sbit SCL_1302=P1^1;
sbit RST
void send_data(unsigned char ch)
{
unsigned char i;
SCL_1302=0;
_nop_();
RST=1;
for(i=0;i<8;i++)
{
}
}
unsigned char receive_data()
{
unsigned char i,data;
SCL_1302=0;
_nop_();
RST=1;
for(i=0;i<8;i++)
{
}
SCL_1302=0;
RST=0;
return data;
}
================================================//
//=======================================应用
sbit SDA_1302=P1^0;
sbit SCL_1302=P1^1;
sbit RST=P1^2;
#define WSEC
#define RSEC
#define WMIN
#define RMIN
#define WHOU
#define RHOU
#define WDAY
#define RDAY
#define WMON
#define RMON
#define WWEEK
#define RWEEK
#define WYEAR
#define RYEAR
#define EWOK
#define EW
#define CDOK
#define CD
void delay(void)
{
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
}
void write_ds1302(unsigned char addr,unsigned char tempdata)
{
}
unsigned char read_ds1302(unsigned char addr)
{
}
void write_initial(void)
{
SCL_1302=0;
RST=0;
write_ds1302(EWOK,0x00);
write_ds1302(WSEC,0X00);
write_ds1302(WMIN,0X00);
write_ds1302(WHOU,0X81);
write_ds1302(WDAY,0X01);
write_ds1302(WMON,0X01);
write_ds1302(WWEEK,0X04);
write_ds1302(WYEAR,0X09);
}
void read(void)
{
DAY=read_ds1302(RDAY);
MONTH=read_ds1302(RMON);
YEAR=read_ds1302(RYEAR);
}
SPI时钟芯片DS130 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)