標(biāo)題: Arduino通信 DS1307 RTC I2C模塊 原理圖及程序分享 [打印本頁(yè)]

作者: happy112    時(shí)間: 2016-6-6 21:39
標(biāo)題: Arduino通信 DS1307 RTC I2C模塊 原理圖及程序分享


功能模塊介紹:

1.此電路板采用DS1307作為I2C實(shí)時(shí)時(shí)鐘芯片(RTC)

2.24C32作為EEPOM存儲(chǔ)器

3.采用LIR2032可充電鋰電池,并帶充電電路,解決了DS1307帶備電池不能讀寫(xiě)的問(wèn)題。

4.可以級(jí)聯(lián)其他的I2C設(shè)備

電路圖:


  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
復(fù)制代碼

全部資料(壓縮包)下載:
I2CRTC模塊.rar (742.75 KB, 下載次數(shù): 74)


作者: fxh_0001    時(shí)間: 2017-4-20 23:22
根本沒(méi)法運(yùn)行

作者: thoulin    時(shí)間: 2017-12-27 10:06
OK,可以參考一下
作者: wpf256    時(shí)間: 2017-12-28 17:41
好東西,感謝樓主的分享





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1