DS12C887.zip

  • 黄逸文
    了解作者
  • C/C++
    开发工具
  • 142KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 11
    下载次数
  • 2013-04-29 15:09
    上传日期
基于AVR单片机的DS12C887时钟驱动程序
DS12C887.zip
  • DS12C887
  • BACKUP
  • ds12c887.c.130325191402
    5.8KB
  • ds12c887.c.130325195226
    6.1KB
  • ds12c887.c.130325191130
    4.6KB
  • ds12c887.c.130325194832
    5.8KB
  • ds12c887.c.130325194650
    5.8KB
  • ds12c887.c.130325191448
    5.8KB
  • ds12c887.c.130325194606
    5.8KB
  • ds12c887.c.130325193450
    5.6KB
  • ds12c887.c.130325194700
    5.8KB
  • ds12c887.c.130325190620
    4.6KB
  • ds12c887.c.130325191536
    5.8KB
  • ds12c887.c.130325194744
    5.8KB
  • ds12c887.c.130325194706
    5.8KB
  • ds12c887.c.130325195208
    6.1KB
  • ds12c887.c.130325191742
    5.6KB
  • ds12c887.c.130325193826
    5.6KB
  • ds12c887.c.130325191458
    5.8KB
  • ds12c887.c.130325190720
    4.6KB
  • ds12c887.c.130325194000
    5.6KB
  • ds12c887.c.130325195548
    6KB
  • ds12c887.c.130325165402
    1.3KB
  • ds12c887.c.130325194848
    5.8KB
  • ds12c887.c.130325195112
    6.1KB
  • ds12c887.c.130325190946
    4.6KB
  • ds12c887.c.130325193416
    5.6KB
  • ds12c887._c
    6KB
  • ds12c887.c.130325194526
    5.8KB
  • ds12c887.c.130325195038
    6.1KB
  • ds12c887.c.130325194556
    5.8KB
  • ds12c887.c.130325193342
    5.6KB
  • ds12c887.c.130325195428
    6.1KB
  • ds12c887.c.130325194934
    5.8KB
  • ds12c887.c.130325190606
    4.6KB
  • ds12c887.c.130325194546
    5.8KB
  • ds12c887.c.130325194636
    5.8KB
  • ds12c887.c.130325195158
    6.1KB
  • ds12c887.c.130325193248
    5.6KB
  • ds12c887.c.130325195708
    6KB
  • ds12c887.c.130325164502
    634B
  • ds12c887.c.130325190750
    4.6KB
  • ds12c887.c.130325170258
    1.8KB
  • ds12c887.c.130325193306
    5.6KB
  • ds12c887.c.130325163910
    264B
  • ds12c887.c.130325193110
    5.6KB
  • ds12c887.c.130325191816
    5.6KB
  • ds12c887.c.130325194756
    5.8KB
  • ds12c887.c.130325193214
    5.6KB
  • ds12c887.c.130325195758
    6KB
  • ds12c887.c.130325195406
    6.1KB
  • ds12c887.c.130325194720
    5.8KB
  • ds12c887.c.130325194952
    5.8KB
  • ds12c887.c.130325194536
    5.8KB
  • ds12c887.c.130325193646
    5.6KB
  • ds12c887.c.130325195258
    6.1KB
  • ds12c887.c.130325190644
    4.6KB
  • ds12c887.c.130325190630
    4.6KB
  • ds12c887.c.130325194912
    5.8KB
  • ds12c887.c.130325190738
    4.6KB
  • ds12c887.c.130325171740
    1.9KB
  • ds12c887.c.130325163308
    1B
  • ds12c887.c.130325193312
    5.6KB
  • ds12c887.c.130325191432
    5.8KB
  • ds12c887.c.130325191756
    5.6KB
  • ds12c887.c.130325195054
    6KB
  • ds12c887.c.130325194840
    5.8KB
  • ds12c887.c.130325195212
    6.1KB
  • ds12c887.c.130325195146
    6.1KB
  • ds12c887.c.130325193534
    5.6KB
  • ds12c887.c.130325191824
    5.6KB
  • ds12c887.c.130325193500
    5.6KB
  • ds12c887.c.130325165228
    1.2KB
  • ds12c887.prj
    1.2KB
  • DS12C887.cof
    6KB
  • DS12C887.hex
    2.9KB
  • DS12C887.lk
    13B
  • DS12C887.lst
    25.2KB
  • DS12C887.dbg
    4.7KB
  • ds12c887.o
    10.6KB
  • DS12C887.mp
    1.9KB
  • DS12C887.SRC
    45B
  • ds12c887.lis
    42.6KB
  • ds12c887.c
    5.9KB
  • DS12C887.mak
    548B
内容介绍
#include<iom16v.h> #include<macros.h> /*********************** MOT-GND //选择Intel模式 SQW //空 AD0~AD7 //PD0~PD7数据总线 IRQ-PB0 //中断请求 REET-VCC//复位脚 DS-PB1 R/W-PB2 AS-PB3 CS-GND ***********************/ #define DS_1 PORTB|=(1<<1) #define DS_0 PORTB&=~(1<<1) #define DS_Out DDRB|=(1<<1) #define RW_H PORTB|=(1<<2) #define RW_L PORTB&=~(1<<2) #define RW_Out DDRB|=(1<<2) #define AS_1 PORTB|=(1<<3) #define AS_0 PORTB&=~(1<<3) #define AS_Out DDRD|=(1<<3) /*#define CS_1 PORTB|=(1<<4) #define CS_0 PORTB&=~(1<<4) #define CS_Out DDRB|=(1<<4)*/ #define RS_0 PORTA &= ~BIT(5); #define RS_1 PORTA |= BIT(5); #define RS_OUT DDRA |= BIT(5); #define RW_0 PORTA &= ~BIT(6); #define RW_1 PORTA |= BIT(6); #define RW_OUT DDRA |= BIT(6); #define E_0 PORTA &= ~BIT(7); #define E_1 PORTA |= BIT(7); #define E_OUT DDRA |= BIT(7); #define DS12887_Second 0x00 //秒 #define DS12887_Minute 0x02 //分 #define DS12887_Hour 0x04 //时 #define DS12887_Week 0x06 //星期 #define DS12887_Day 0x07 //日 #define DS12887_Month 0x08 //月 #define DS12887_Year 0x09 //年 unsigned char DateString[9]; unsigned char TimeString[9]; //定义时间类型,结构体数据类型 typedef struct _SYSTEMTIME_ { unsigned char Second; unsigned char Minute; unsigned char Hour; unsigned char Week; unsigned char Day; unsigned char Month; unsigned char Year; }SYSTEMTIME; void delay_ms(unsigned int xms) { unsigned int i,j; for(i=0;i<xms;i++) for(j=0;j<1140;j++); } void write_com(unsigned char com) { RS_1; RW_1; E_0; RS_0; RW_0; PORTC = com; delay_ms(1); E_1; delay_ms(1); E_0; } void write_data(unsigned char data) { RS_0; RW_1; E_0; RS_1; RW_0; PORTC = data; delay_ms(1); E_1; delay_ms(1); E_0; } int lcd_init(void) { DDRC = 0XFF; PORTC = 0; RS_OUT; E_OUT; RW_OUT; delay_ms(20); write_com(0x38); delay_ms(5); write_com(0x38); delay_ms(5); write_com(0x38); write_com(0x38); write_com(0x08); write_com(0x01); write_com(0x06); write_com(0x0C); } void port_init(void) { DDRB = 0xFF; PORTB = 0xFF; DDRD = 0x00; PORTD = 0x00; } /**DS12C887写数据**/ void DS12C887_Write(unsigned char add,unsigned char dat) { AS_0; _NOP(); _NOP(); DS_1; _NOP(); _NOP(); RW_H; _NOP(); _NOP(); AS_1; _NOP(); _NOP(); DDRD=0xff; _NOP(); _NOP(); _NOP(); _NOP(); PORTD=add; _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); AS_0; _NOP(); _NOP(); RW_L; _NOP(); _NOP(); _NOP(); PORTD=dat; _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); RW_H; _NOP(); _NOP(); _NOP(); AS_1; _NOP(); _NOP(); } /**在DS12C887指定地址中读数据**/ unsigned char DS12C887_Read(unsigned char add) { unsigned char temp=0; AS_0; _NOP(); _NOP(); DS_1; _NOP(); _NOP(); RW_H; _NOP(); _NOP(); AS_1; _NOP(); _NOP(); DDRD=0xff; _NOP(); _NOP(); _NOP(); _NOP(); PORTD=add; _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); AS_0; _NOP(); _NOP(); DS_0; _NOP(); _NOP(); DDRD=0x00; _NOP(); _NOP(); _NOP(); _NOP(); temp=PIND; _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); _NOP(); DS_1; _NOP(); _NOP(); AS_1; _NOP(); _NOP(); return temp; } /**DS12C887初始化函数**/ void DS12C887_Init(void) { DS12C887_Write(0x0a,0x20); DS12C887_Write(0x0b,0x86); DS12C887_Write(0x0b,0x06); } /**DS12C887设置时间函数**/ void DS12C887_SetTime(unsigned char add,unsigned char dat) { DS12C887_Write(0x0b, 0x86); //禁止更新,接下来初始化数据,即写入时间,日期等 DS12C887_Write(add,dat); DS12C887_Write(0x0b, 0x06); //正常更新,二进制格式,24进制小时 } /**DS12C887读出时间函数**/ void DS12C887_GetTime(SYSTEMTIME *Time) { unsigned char temp; Time->Second = DS12C887_Read(DS12887_Second); Time->Minute = DS12C887_Read(DS12887_Minute); Time->Hour = DS12C887_Read(DS12887_Hour ); Time->Day = DS12C887_Read(DS12887_Day ); //Time->Week = DS12887_Read(DS12887_Week ); Time->Month = DS12C887_Read(DS12887_Month ); Time->Year = DS12C887_Read(DS12887_Year ); } /*********************日期转化成字符 09-02-19************/ void DateToStr(SYSTEMTIME *Time) { DateString[0] = Time->Year/10 + '0'; DateString[1] = Time->Year%10 + '0'; DateString[2] = '-'; DateString[3] = Time->Month/10 + '0'; DateString[4] = Time->Month%10 + '0'; DateString[5] = '-'; DateString[6] = Time->Day/10 + '0'; DateString[7] = Time->Day%10 + '0'; //DateString[8] = '\0'; } /*********************时间转化成字符***********************************/ void TimeToStr(SYSTEMTIME *Time) { TimeString[0] = Time->Hour/10 +'0'; TimeString[1] = Time->Hour%10 +'0'; TimeString[2] = ':'; TimeString[3] = Time->Minute/10 + '0'; TimeString[4] = Time->Minute%10 + '0'; TimeString[5] = ':'; TimeString[6] = Time->Second/10 + '0'; TimeString[7] = Time->Second%10 + '0'; //TimeString[8] = '\0'; } void main(void) { SYSTEMTIME CurrentTime; //unsigned char DateString[9]; //unsigned char TimeString[9]; unsigned char temp; unsigned char i; port_init(); lcd_init(); DS12C887_Init(); //只读时间的时候可以屏蔽该句 DS12C887_GetTime(&CurrentTime); /*************时间初始化设置 ,2009-3-4 16:57:00************/ //时钟调准后屏蔽该段程序 //* DS12C887_SetTime(DS12887_Second, 0); //设置秒 DS12C887_SetTime(DS12887_Minute, 57); //设置分 DS12C887_SetTime(DS12887_Hour,16); //设置时 DS12C887_SetTime(DS12887_Day, 4); //设置天 DS12C887_SetTime(DS12887_Month, 3); //设置月 DS12C887_SetTime(DS12887_Year, 9); //设置年 while(1) { DS12C887_GetTime(&CurrentTime); DateToStr(&CurrentTime); TimeToStr(&CurrentTime); write_com(0x80); for(i=0;i<16;i++) { write_data(DateString[i]); delay_ms(2); } write_com(0x80+0x40); for(i=0;i<16;i++) { write_data(TimeString[i]); delay_ms(2); } } }
评论
    相关推荐
    • DS12C887.rar
      该程序基于STC89C52的DS12C887时钟程序,测试通过,且能稳定运行,请放心使用。
    • DS12C887.rar
      ds12cr887源程序,亲测可用。可以实现精确计时,闹钟定时等功能。
    • ds12c887时钟.rar
      51单片机驱动DS12C887时钟芯片制作的LCD时钟,有温湿度,农历显示
    • ds12c887.zip
      实时时钟ds12c887驱动程序,atmega128平台测试通过
    • DS12c887.zip
      C51程序运用stc12c5a系列的单片机即可驱动,DS12c887时钟芯片的正常工作,利用共阴数码管显示。已测试完成。
    • RTC_DS12C887.zip
      使用keil编程,用51单片机和DS12C887芯片实现实时时钟
    • DS12C887.zip
      DS12C887是一款时钟芯片,精度高,误差小。驱动简单。
    • DS12C887程序
      DS12C887程序.可以助你一臂之力。C语言更能懂
    • 仿真 ds12c887时钟芯片
      ds12c887时钟芯片仿真 ,c语言写的,参照郭天详
    • DS12C887时钟51程序
      压缩包包括调好的DS12C887时钟51单片机的C语言程序,以及需要的参考资料。