Go Down

Topic: DS1306, set Date Time (Read 1 time) previous topic - next topic

SpcCode

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: [Select]
  //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...

PaulS

Code: [Select]
  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: [Select]
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?


SpcCode

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

The output error is the following:

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

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

PaulS

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.

floresta

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

floresta

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

Nick Gammon


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: [Select]
// 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: [Select]
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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up