Rtc info

ac21

Member
I got this RTC from ebay.

It has six pads numbered 1-3(shown in attached pic), is this some address selection for communication? i cant find any info on the web about it.

This should have the 4.7k pull up resisters already on the board correct?
 

Attachments

SAborn

Senior Member
The RTC is a DS1307 chip so the address for the RFC will be factory set and can not be changed, although it also looks to have a eeprom chip on the board as well which may likely have selectable address choices, i cant read the part numbers on the chip to know what chip it is.

As for pullups, the simplest way is to do a ohm test between Scl and Vcc and Sda and Vcc, as you should get around 4700 ohm reading is the pullups are on the board.

Also looks to have a backup battery input, this might need to be connected for the RTC to work, have a read of the DS1307 RTC data sheet and it will tell you what you need to do.
 

lbenson

Senior Member
I have similar boards. It should have the 4K7 pullups already onboard. The DS line is for a DS18B20 temperature IC--it would go in the three holes in the upper right. The SQ is for the one second square wave out of the RTC.

The eeprom is probably 4K, with the programmable address bits set at 000, though I have some DS3221 RTC modules where it is 111.

I'm not sure what your address pads are for--might be to change the address of the eeprom.
 

MLPINTO

New Member
Items marked as 1,2,3, are used to change the direction of the circuit I2C EEPROM. It is different from the direction of the watch ( is $ D0 ).
The EEPROM address can be any of the following: $ A0, $ A2, $ A4, A6 $, $ A8, $ AA $ AC, $ AE. Amending bypassing one, two, three (or none), the points marked ,
with the point to the left or right, ( connected to Vcc or Gnd). For example, bridge 1 and 2 to Gnd and Vcc to 3, would give us the I2C address $ A8.
 

ac21

Member
I used marks and randy's code..
what is the variable "day" B11?

Code:
      SYMBOL character1    = B2
	SYMBOL character2    = B3  
	SYMBOL character3    = B4  
	SYMBOL character4    = B5  
	SYMBOL character5    = B6  
	SYMBOL character6    = B7
	SYMBOL hours         = B8
      SYMBOL mins          = B9
	SYMBOL secs          = B10
	SYMBOL day           = B11 
	SYMBOL date          = B12  
	SYMBOL month         = B13
	SYMBOL year          = B14
	SYMBOL PM_AM         = B15 
	 
Program:            
   HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte       ' set to 100kbps 
       HI2Cout $0,  ( $40, $58, $10 ,day, $02, $02 , $14) ' write time to ds3231 or ds1307  example (11.58.00 PM)
'prog time          (secs,mins,hours,day,date,month,year) ' enter hours in 24 hour format ( $0 to $23 )

Main: 
pause 1000
       HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte        
	 HI2Cin $0,   (secs,mins,hours,day,date,month,year) ' read time 
	 
ClockDisplay:
    PM_AM ="P" : IF hours < $12 then :PM_AM = "A" : ENDIF       'indicate PM  or AM
    
    IF hours = $20 OR hours = $21 THEN : LET hours = hours - $6 : ENDIF
    IF hours > $12 THEN : LET hours = hours - $12 : ENDIF       '24 to 12 hour format
    IF hours = $0 THEN  : hours = $12 : ENDIF
    
   BcdTOASCII hours,character1,character2 : IF character1 = "0" THEN : character1 = " " : ENDIF ' zero blanking character1
   BcdTOASCII mins ,character3,character4
   BcdTOASCII secs ,character5,character6 
 sertxd (CR,LF,character1,character2,".",character3,character4,".",character5,character6," ",PM_AM,"M    ") '(11.58.00 PM)
 
DateMonthYearDisplay:
   BcdTOASCII date ,character1,character2
   BcdTOASCII month,character3,character4
   BcdTOASCII year ,character5,character6
 sertxd (character1,character2,"/",character3,character4,"/20",character5,character6,CR,LF)' (05/11/13)
   
 ;http://www.picaxeforum.co.uk/showthread.php?18505-DS1307-Code-Examples
   

     goto main
 

ac21

Member
It looks like its 1-7
Capture.PNG

The DS1307 can be run in either 12 hour or 24 hour mode. Bit 6 of the hours register is defined as the 12 hour or 24 hour mode select bit. When high, the 12 hour mode is selected. In the 12 hour mode, bit 5 is the AM/PM bit with logic high being PM. In the 24 hour mode, bit 5 is the second 10 hour bit (20 to 23 hours). The hours value must be reentered whenever the 12/24 hour mode bit is changed
how do i know if i'm in 12 or 24 hour mode? what does logic high mean?
 

Paix

Senior Member
Logic high = 1
Logic low = 0

12/24 hour mode set bit 6 of address 02h to 0 for 12 hour mode and to 1 for 24 hour mode. How do you tell which mode you are in?
In 24 hour mode 1259 will be followed by 1300, in 12 hour mode, IT WON'T. :)
 

ac21

Member
Code:
sertxd (hours)
is returning in 24 hour format

I want a loop to occur untill it sees three differant time pirods, but when i do this i get a error, the manual only says its possible but not recommended

Code:
		        do
                               something....
                        loop until day = $01 and hours => $6 and hours =< $24 or
			             day <> $01 and hours => $6 and hours =< $9 or
			             day <> $01 and hours => $18 and hours =< $23 
                                     goto btime
how can make this happen?
 

lbenson

Senior Member
I'm not sure whether you're talking about a logic problem or a syntax problem. If the latter, can you do this?

Code:
do
  if ... then exit
  if ... then exit
  if ... then exit
loop
or

Code:
do
  if ... then btime
  if ... then btime
  if ... then btime
loop
 

ac21

Member
it was syntax.

what i see from simulation what works is changing the loop to a label like so...

Code:
                    strobe1:    
                             something....
			     if day = $01 and hours => $6 and hours =< $24 then gosub btime
		             if day <> $01 and hours => $6 and hours =< $9 then gosub btime
		             if day <> $01 and hours => $18 and hours =< $23 then gosub btime
	            goto strobe1
 
Top