Pages: [1]   Go Down
Author Topic: DS1306, set Date Time  (Read 1022 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am trying to set up the date time of the DS1306 Real Time Clock. I am using the source code from here: http://www.nearfuturelaboratory.com/2006/12/14/arduino-and-ds1306-real-time-clock/.

I changed it a little bit to save the current date and time.

What I added is this on the setup section:
Code:
  //set datetime
  write_rtc_register(0x80, 0x00); // set seconds
  write_rtc_register(0x81, 0x45); // set the minutes
  write_rtc_register(0x82, 0x11); // set hours
  write_rtc_register(0x83, 0x07); // monday = 1...etc
  write_rtc_register(0x84, 0x08); // set date
  write_rtc_register(0x85, 0x05); // month
  write_rtc_register(0x86, 0x11); // year 00-99

DS1306Arduino
Pins 1,8GND
Pins 16,14,9 5V
Pin 2 3V
Pin 3,4 Crystal
Pin SDO,SDI,SCLK Pins 12,11,13
Pin 10 Pin 6
Pin 6(+10k in Vcc) Pin 3

But the output in the serial monitor just throw zeros...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49027
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  write_rtc_register(0x82, 0x11); // set hours
Since 0x11 is 17, that may not be valid, if the input is limited to 0 to 11.

Code:
write_rtc_register(0x81, 0x45); // set the minutes
0x45 is 69 in base 10. Not too many hours have 69 minutes.

Quote
I am using the source code from here
Quote
I changed it a little bit to save the current date and time.
What I added is this on the setup section:
Are you sure that the register addresses you specified are valid?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the data sheet to see which register I need to look at.

The output error is the following:

Code:
CTRL REG [FFFFFFFF]
STATUS REG [11111111111111111111111111000010]
YEAR [FFFFFFFF]
MONTH [5F]

sec alarm is FF SECS=FF MINS=FF HRS=C1
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49027
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That site you linked to is a perfect example of how not to develop a web site. I can't read a damned thing on that page. Sorry I can't help you.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That site you linked to is a perfect example of how not to develop a web site. I can't read a damned thing on that page. Sorry I can't help you.
It probably looks really nice on his monitor with his browser.  He must be fairly young as well judging from the font size.

Don
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

Quote
 write_rtc_register(0x82, 0x11); // set hours
Since 0x11 is 17, that may not be valid, if the input is limited to 0 to 11.

Quote
write_rtc_register(0x81, 0x45); // set the minutes
0x45 is 69 in base 10. Not too many hours have 69 minutes.

I think these may be OK, the RTC stores it's data in binary coded decimal format.


Don
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18720
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That site you linked to is a perfect example of how not to develop a web site. I can't read a damned thing on that page. Sorry I can't help you.



Arrrgh! My eyes!

Honestly, it's almost impossible to read the code, and the download link is not valid. But anyway, in what I can barely make out is the source is this:

Code:
// ATMega8 Code
// ATMega8 Code
#define DATAOUT 11 //MOSI
#define DATAIN  12 //MISO
#define SPICLOCK  13 //sck
#define RTC_CHIPSELECT 7 // chip select (ss/ce) for RTC, active high
#define LED 10

You had:


Code:
DS1306 Arduino
Pins 1,8 GND
Pins 16,14,9 5V
Pin 2 3V
Pin 3,4 Crystal
Pin SDO,SDI,SCLK Pins 12,11,13
Pin 10 Pin 6
Pin 6(+10k in Vcc) Pin 3

You have Chip Enable (pin 10 on the device) connected to pin 6, but the code requires pin 7.

If that isn't the answer, how about posting the whole sketch?
Logged


Pages: [1]   Go Up
Jump to: