DS1302
实现流程
将提供的ds1302底层参考程序拷贝到工程下
注意在ds1302.c中可能硬件引脚没有定义,注意去看一下。还有头文件什么的在ds1302中记得加上
参考代码:
c
#include "reg52.h"
#include "ds1302.h"
unsigned char Write_DS1302_adrr[7] = {0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};
unsigned char Read_DS1302_adrr[7] = {0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
unsigned char Timer[7] = {0x24,0x59,0x23,0x18,0x04,0x06,0x20};
void DS1302_Config()
{
char i;
Write_Ds1302_Byte(0x8e,0x00);
for(i=0;i<7;i++)
{
Write_Ds1302_Byte(Write_DS1302_adrr[i],Timer[i]);
}
Write_Ds1302_Byte(0x8e,0x80);
}
void Read_DS1302_Timer()
{
char i;
for(i=0;i<7;i++)
{
Timer[i] = Read_Ds1302_Byte(Read_DS1302_adrr[i]);
}
}
void main()
{
while(1)
{
}
}