View Full Version : ds 1307 revisted
jcleaver
- 9th February 2007, 16:43
still having problems starting the clock
any suggestions seem to have program correct just clock dont want to start
have pullup on sda and scl
grounded batt connection
have 5 volts
and send a $00 to secs to init
help??
BobK
- 9th February 2007, 21:15
Hi jcleaver,
Well the obvious things to check are the crystal, the SDA and SCL pins aren't reversed, the sec.7 setting and the batt pin grounded or connected to a battery.
I personally use the DS1337 RTC. It doesn't have a batt pin and it doesn't have a startup register to set. BUT, when I first started using it I thought any 32K crystal would work. I was way off on that one. Every one of my clocks gained time and fast! Reading the fine print in the datasheet for the 1337 RTC shows the crystal needs to have a 6pf capacitance load. Bought the right crystal and they haven't missed a beat yet! Back to your problem.
Triple check the SDA and SCL pins to make sure they aren't reversed. Just for the hell of it, read and display RTCSec.7 to make sure it is set to 0. I know I read your posts about sending a $00 to the sec register but I would at least try sending RTCSec.7 = 0 to see if the clock doesn't start running.
I would also try setting up the mentioned program from Melanie MN1307. At least here you know for sure the program works. If you 1307 works in her program then you've got some direction to look in.
I've done several projects now with the DS1337 and I haven't had any problems other than the crystal.
HTH,
BobK
BobK
- 9th February 2007, 21:44
Hi jcleaver,
Well the obvious things to check are the crystal, the SDA and SCL pins aren't reversed, the sec.7 setting and the batt pin grounded or connected to a battery.
I personally use the DS1337 RTC. It doesn't have a batt pin and it doesn't have a startup register to set. BUT, when I first started using it I thought any 32K crystal would work. I was way off on that one. Every one of my clocks gained time and fast! Reading the fine print in the datasheet for the 1337 RTC shows the crystal needs to have a 6pf capacitance load. Bought the right crystal and they haven't missed a beat yet! Back to your problem.
Triple check the SDA and SCK pins to make sure they aren't reversed. Just for the hell of it, read and display RTCSec.7 to make sure it is set to 0. I know I read your posts about sending a $00 to the sec register but I would at least try sending RTCSec.7 = 0 to see if the clock doesn't start running.
I would also try setting up the mentioned program from Melanie MN1307. At least here you know for sure the program works. If you 1307 works in her program then you've got some direction to look in.
I've done several projects now with the DS1337 and I haven't had any problems other than the crystal.
HTH,
BobK
jcleaver
- 10th February 2007, 00:28
bob thanks for the update
where did you get the right crystal? part #
and where can you find info on the rtcsec command?
melanies programj looks great but cannot make it work not smart enough to know whats wrong
only one works seems to do ok most of the time have listed for any responces
still need to work on serring the clock
again thanks
jack' PicBasic Pro program to display result of
' 8-bit A/D conversion on LCD
'
' Connect analog input to channel-0 (RA0)
@ DEVICE pic16f877a, HS_OSC, WDT_ON, PWRT_ON, LVP_OFF, PROTECT_OFF
' Define LCD registers and bits
Define LCD_DREG PORTB ' Port for LCD Data
Define LCD_DBIT 4 ' Use upper 4 bits of Port
Define LCD_RSREG PORTB ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 3 ' Port Pin for RS bit
Define LCD_EREG PORTB ' Port for Enable (E) bit
Define LCD_EBIT 2 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
DEFINE OSC 20
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
define loader_used 1
adval var byte ' Create adval to store result
AD33 VAR BYTE
W1 VAR WORD 'PUSHBUTTON
I VAR WORD
TRISA = %11111111 ' Set PORTA to all input
TRISD = %11111111 ' SET PORTD TO INPUT
ADCON1 = %00000010 ' Set PORTA analog
' Low PORTE.2 ' LCD R/W line low (W)
' Define I2C bus ports
B0 VAR BYTE
B1 VAR BYTE
B2 VAR BYTE
SDA VAR PORTC.4 'DS1307 SDA pin
SCL VAR PORTC.3 'DS1307 SCL pin
DEFINE I2C_SLOW 1
DEFINE I2C_HOLD 1
DEFINE I2C_SCLOUT 1
Pause 500 ' Wait .5 second
ADDR VAR BYTE
ADDR = 0
PAUSE 1000
CONT CON %11010000
secs var byte
mins var byte
hrs var byte
day var byte
date var byte
month var byte
year var byte
ctrl var byte
x var byte
x=0
for x= 1 to 5
I2CWRITE SDA,SCL,CONT,ADDR,[$00,$59,$11,$03,$25, $12 ,$03, $10]
PAUSE 500
next x
'I2CREAD SDA,SCL,CONT,ADDR ,[b2]
loop:
COUNT portd.1,750,w1
lcdout $fe,1
pause 1000
lcdout $fe,$80+4 ,"count: ", dec w1
pause 500
I2CREAD SDA,SCL,CONT,ADDR ,[secs,mins,hrs,day,date,month,year,ctrl]
pause 5000
ADCIN 0, adval ' Read channel 0 to adval
ADCIN 1, AD33
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", # adval ' Display the decimal value
LCDOUT $FE,$C0, "VALUE : ", DEC AD33
Pause 500 ' Delay for .5 seconds
lcdout $fe,1 ' clear display
lcdout "min: ", hex mins
lcdout $FE,$C0,"secs: ",hex secs
pause 1000
Goto loop ' Do it forever
End
seem to have something strange about my setup
wish i knew
BobK
- 10th February 2007, 02:16
Hi Jack,
1. The DS1307 needs a crystal with a 12.5pf load. That part # is DigiKey SE3201-ND or SE3202-ND or SE3203-ND. The difference between them is physical size with the 3201 being the largest and the 3203 being the smallest and the more expensive. 3201 and 3202 are $.27 in single lot and the 3203 is $1.38 single lot. You can find them on page 1135 of their current catalog.
2. RTCsec came from the MN1307 program. You have your "secs" register which is the same thing.
3. If I were you, at this point, I would strip the program down and only put the LCD items in there first, make sure the LCD works, then I would add just the clock stuff. I have attached a DS1307 program I got off of another PIC group. I do believe our own Darrel Taylor was a part of the discussion on getting the clock chip to work. When you look at this program you will see that there are RTC register assignments as constants. You don't seem to have them in what you posted here. This may be part of the problem. This listing I have attached is very close to what I have for my DS1337 program. Try this program just with the LCD portion of your program and see if it doesn't get you going. You shouldn't have to make any pin assignment changes. SDA and SCL are the same pins.
You can set the time values to your current time, just make sure the secs are set to $00.
You're having fun.... you just don't know it. This programming stuff is frustrating as all hell but once you get it to work you won't forget it!
HTH,
BobK
Let me know how this works for you.
jcleaver
- 10th February 2007, 14:10
thanks for takeing your time with me i was able toget your program running
i have different lcdout commands but was a simple fix
will continue to try to devolpe
boy are we haveing fun now next lets go out and shoot off our toes (ha ha)
thanks again
BobK
- 10th February 2007, 15:00
Hi Jack,
Glad to hear you got it working!
My big thing now is to get the serial LCD module from Wulden.org to work. It displays the data but you can't control where it's suppose to be. It's based on the PHAnderson "chip" and has sometype of ASCII command set that is different from the other adaptors out there.
I use an RTC in almost everything I build. This forum has been a big help for me.
Have a nice day!
BobK
jcleaver
- 10th February 2007, 18:00
where is there a usa dist for this?
BobK
- 10th February 2007, 18:58
Hi Jack,
What are you looking to buy?
BobK
jcleaver
- 17th February 2007, 14:10
just trying to find a good clock setup thought the serial lcd driver
would help
also clock is gaining time have to see where to get the correct crystals for this
oops clock is loseing time greatly
any info
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.