|
xpress_embedo
Active Member
Offline
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« Reply #1 on: February 25, 2014, 05:45:29 17:45 » |
|
Ds1307 works on i2c protocol. So first of all you should learn about i2c protocol, mikroc has inbuilt function for this.
Then initially you have to set the time by any means and then after that place a 3.3v battery on rtc battery backup pin, and it will retain and increment the value.
Posted on: February 25, 2014, 06:38:19 18:38 - Automerged
In the temperature logger project, i had posted there is full code for DS1307, but the problem for you is that how you will set initial time and date. My advice for this is that, use serial port and send a packet which contains time and date information, and on controller end decode this packet and extract time and date information then write it to rtcc.
|
|
|
Logged
|
|
|
|
|
Unhappy
Senior Member
Offline
Posts: 282
Thank You
-Given: 1005
-Receive: 101
|
|
« Reply #3 on: February 25, 2014, 08:23:48 20:23 » |
|
Dear catcatcat That page is in cyrillics any with english language please
|
|
|
Logged
|
|
|
|
gan_canny
Junior Member
Offline
Posts: 89
Thank You
-Given: 101
-Receive: 26
|
|
« Reply #4 on: February 25, 2014, 08:49:51 20:49 » |
|
Well something to be aware of is the notation used for the Ds1307. The notation represents time and date as BCD ( Binary code decimal). A notational issue is the hours..12 hour and 24 hour are encoded differently and the days of the week notation (1..7).
With BCD the nibble ( 4 bits) notate a number 0..9 so the most significant nibble is ten times the value of the least significant nibble.
Now odds are that your microcomputer is binary with word lengths 8 16 24 32 etc. You will need to convert the notation from BCD when reading the DS1307 and the reverse when writing. This is a number base conversion but since time and date are whole numbers no notational inaccuracies will occur. So take the most significant BCD digit shift it left 3 times to get a multiply by 8(decimal) and add the digit back in after shifting left one time ( 8+2=10) then add in the least significant BCD digit to get a binary notation of the BCD notation.
As mentioned above data move into and out of the ds1307 via an electrical convention I2C....This is a serial protocol with a data line and a clock line....Since I2C is a shared interface any connected device has to be able to drive the line down to ground..this means devices don't drive the line high ..instead pull up resistors are used. I2C needs pull up resistors about 2k to 4k. Next the ds1307 has a battery backup so the power supplied must equal or exceed the battery voltage when accessing the device.
|
|
« Last Edit: February 25, 2014, 08:59:53 20:59 by gan_canny »
|
Logged
|
|
|
|
cadence
Junior Member
Offline
Posts: 93
Thank You
-Given: 103
-Receive: 430
|
|
« Reply #5 on: February 27, 2014, 03:24:44 03:24 » |
|
Take a look at the examples file Mikroelektronika provides for free for use with their range of compilers at the following link: http://www.mikroe.com/downloads/get/258/rtc2_examples.zipIt's for their RTC breakout board based on the DS1307 ( http://www.mikroe.com/add-on-boards/rtc/rtc2/), but the examples provided are in Basic, Pascal and C for a range of different micros - including the PIC. They're are also small enough to compile in the demo versions of their compilers too. The Mikroe page also includes a link to the Maxim site where there's a link to App Note 3921: Using a DS1307 with a PIC Microcontroller. Hope this helps.
|
|
|
Logged
|
|
|
|
Catcatcat
Senior Member
Offline
Posts: 432
Thank You
-Given: 284
-Receive: 1654
|
|
« Reply #6 on: February 27, 2014, 06:58:43 06:58 » |
|
Dear catcatcat That page is in cyrillics any with english language please
Right switch from Google Translator Technology
|
|
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Online
Posts: 4667
Thank You
-Given: 834
-Receive: 4323
There is no evidence that I muted SoNsIvRi
|
|
« Reply #7 on: March 06, 2014, 01:20:39 13:20 » |
|
here his the full circuit for the Tiny RTC pcb that is on ebay and other sites.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
jobitjoseph1
Junior Member
Offline
Posts: 44
Thank You
-Given: 18
-Receive: 178
|
|
« Reply #8 on: March 15, 2014, 03:47:20 15:47 » |
|
You have to load the time value to the chips registers through i2c protocol
|
|
|
Logged
|
|
|
|
user77
Newbie
Offline
Posts: 11
Thank You
-Given: 0
-Receive: 4
|
|
« Reply #9 on: May 10, 2014, 10:38:31 22:38 » |
|
to start oscillator remember that you must set to 0 the CH bit (the most important bit of second byte) to do this you can mask second byte with 7F (AND between second value and 7F).
|
|
|
Logged
|
|
|
|
Crackn
Active Member
Offline
Posts: 130
Thank You
-Given: 121
-Receive: 565
|
|
« Reply #10 on: May 23, 2014, 09:24:15 21:24 » |
|
Hello,
the easy way to set the time/date to rtc module is using an arduino board and a DS1307 example sketch named Set Time. just open the arduino ide and load the example. you will need an arduino and an usb cable to play with.
cya
|
|
|
Logged
|
|
|
|
|