找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9571|回复: 3
打印 上一主题 下一主题
收起左侧

Arduino通信 DS1307 RTC I2C模块 原理图及程序分享

[复制链接]
跳转到指定楼层
楼主


功能模块介绍:

1.此电路板采用DS1307作为I2C实时时钟芯片(RTC)

2.24C32作为EEPOM存储器

3.采用LIR2032可充电锂电池,并带充电电路,解决了DS1307带备电池不能读写的问题。

4.可以级联其他的I2C设备

电路图:


  1. /*
  2.   DS1307.h - library for DS1307 rtc
  3. */

  4. // ensure this library description is only included once
  5. #ifndef DS1307_h
  6. #define DS1307_h

  7. // include types & constants of Wiring core API
  8. #include <WConstants.h>

  9. // include types & constants of Wire ic2 lib
  10. #include <../Wire/Wire.h>

  11. #define DS1307_SEC 0
  12. #define DS1307_MIN 1
  13. #define DS1307_HR 2
  14. #define DS1307_DOW 3
  15. #define DS1307_DATE 4
  16. #define DS1307_MTH 5
  17. #define DS1307_YR 6

  18. #define DS1307_BASE_YR 2000

  19. #define DS1307_SQW1HZ  7
  20. #define DS1307_SQW4KHZ 8
  21. #define DS1307_SQW8KHZ 9
  22. #define DS1307_SQW32KHZ 10

  23. #define DS1307_CTRL_ID B1101000  //DS1307

  24. // Define register bit masks
  25. #define DS1307_CLOCKHALT B10000000

  26. #define DS1307_LO_BCD  B00001111
  27. #define DS1307_HI_BCD  B11110000

  28. #define DS1307_HI_SEC  B01110000
  29. #define DS1307_HI_MIN  B01110000
  30. #define DS1307_HI_HR   B00110000
  31. #define DS1307_LO_DOW  B00000111
  32. #define DS1307_HI_DATE B00110000
  33. #define DS1307_HI_MTH  B00110000
  34. #define DS1307_HI_YR   B11110000


  35. // Prescaler
  36. #define DS1307_LOW_BIT      B00000000
  37. #define DS1307_HIGH_BIT     B10000000
  38. #define DS1307_SQW1HZ_BIT   B00010000
  39. #define DS1307_SQW4KHZ_BIT  B00010001
  40. #define DS1307_SQW8KHZ_BIT  B00010010
  41. #define DS1307_SQW32KHZ_BIT B00010011

  42. // library interface description
  43. class DS1307
  44. {
  45.   // user-accessible "public" interface
  46.   public:
  47.     DS1307();
  48.     void get(int *, boolean);
  49.     int get(int, boolean);
  50.     void set(int, int);
  51.     void start(void);
  52.     void stop(void);
  53.     void SetOutput(int c);
  54.     int GetOutput(void);
  55.    
  56.   // library-accessible "private" interface
  57.   private:
  58.     byte rtc_bcd[7]; // used prior to read/set ds1307 registers;
  59.     void read(void);
  60.     void save(void);
  61. };

  62. extern DS1307 RTC;

  63. #endif
复制代码

全部资料(压缩包)下载:
I2CRTC模块.rar (742.75 KB, 下载次数: 74)

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:191864 发表于 2017-4-20 23:22 | 只看该作者
根本没法运行
回复

使用道具 举报

板凳
ID:124722 发表于 2017-12-27 10:06 | 只看该作者
OK,可以参考一下
回复

使用道具 举报

地板
ID:268463 发表于 2017-12-28 17:41 | 只看该作者
好东西,感谢楼主的分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表