You were absolutely right. Once I converted from DCD to dec it worked fine. I did change to the 1302 chip though. I had a couple laying around. I looked at this far too long and didn't see the forest for the burnt and smoldering stumps from my flamethrower. Thanks a bunch Gary -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Paul Hutchinson Sent: Friday, November 08, 2002 8:41 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: DS1202 Hello techhead?, You will probably get better responses if you use a subject topic tag. Many of the list members, including many of the most experienced/knowledgeable members, don't receive untagged posts. See www.piclist.com for topic tag information details. Also including your real name may help as some people won't respond to anonymous posts. I'm not familiar with the DS1202 and I also don't know the programming language you're using (looks like BASIC?) so, this may not help much. There is no datasheet for it at the Dallas semi website (appears to be an obsolete part) but, I did find the chip in a 1992 Dallas data book. My first thought was that maybe you had a floating battery input terminal which causes all sorts of strange behaviors in RTC chips but, I see that this chip does not have a battery pin. Reading over the data sheet I see that this chip uses BCD for all the data. It looks like your code is treating the data as binary instead of BCD? Your report of the count sequence almost matches a BCD vs. binary count but not quite. bit pattern BCD value binary value 00010000 10 16 01011001 59 89 Another thing I noticed in the data sheet is that bit 7 (MSB) is the clock halt flag and needs to be ignored when reading the time. Finally, this chip is not Y2K compliant so, if you've set the year to "02" it thinks the date is 1902 which could be exposing a bug in the chip. Try setting the year to a value greater than 1990. I still get a chuckle thinking about the first AT clone PC I used. One day it refused to boot but everything tested OK with the diagnostics disk. This stumped me and the IT manager and he was ready to send it back to the manufacturer. I kept looking around at settings and finally noticed that somehow the year got changed to 1934, setting the date to the right year of 1985 fixed the PC. I told the IT manager about it and said "In 1934 PC's didn't exist yet so I guess the BIOS sees the date and says shutdown I can't exist yet" :-). IMHO, you should probably trash the DS1202 and get a currently produced version of a Dallas RTC chip. I saw a reference to using a DS1302 to replace a DS1202 on the Dallas web site. Myself I like the DS1307, I2C interface, Y2K compliant and, keeps time for years on a single lithium coin cell. Hope this helps, Paul Hutch > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of techhead > Sent: Friday, November 08, 2002 7:07 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: DS1202 > > > I have a DS1202 clock that is sort of running. It doesn't count > correctly. It starts at 0 seconds then counts up to 9 then jumps to 15 > counts for a bit then jumps again and counts then jumps and it counts > all the way to 99 seconds then rolls over. I have included my code > below. Any help would be appreciated. > > Include "MODEDEFS.BAS" ' Include Shiftin/out modes > > DEFINE OSC 4 > 'Define LCD_DREG PORTD ' Define LCD connections > 'Define LCD_DBIT 4 > 'Define LCD_RSREG PORTE > 'Define LCD_RSBIT 0 > 'Define LCD_EREG PORTE > 'Define LCD_EBIT 1 > > ' Alias pins > RST var PORTB.4 > IO var PORTB.1 > SCLK var PORTB.3 > Lout var PORTB.2 > > ' Allocate variables > rtcyear var byte > rtcday var byte > rtcmonth var byte > rtcdate var byte > rtchr var byte > rtcmin var byte > rtcsec var byte > rtccontrol var byte > > > Low RST ' Reset RTC > Low SCLK > > OPTION_REG.7 = 0 ' Enable PORTB pullups > > Pause 10 ' Wait for LCD to startup > > ' Set initial time to 8:00:00AM 06/06/02 > rtcyear = $02 > rtcday = $06 > rtcmonth = $06 > rtcdate = $06 > rtchr = $08 > rtcmin = 0 > rtcsec = 0 > Gosub settime ' Set the time > > Goto mainloop ' Skip subroutines > > > ' Subroutine to write time to RTC > settime: > RST = 1 ' Ready for transfer > > ' Enable write > Shiftout IO, SCLK, LSBFIRST, [$8e, 0] > > RST = 0 ' Reset RTC > > RST = 1 ' Ready for transfer > > ' Write all 8 RTC registers in burst mode > Shiftout IO, SCLK, LSBFIRST, [$be, rtcsec, rtcmin, rtchr, > rtcdate, rtcmonth, rtcday, rtcyear, 0] > > RST = 0 ' Reset RTC > Return > > ' Subroutine to read time from RTC > gettime: > RST = 1 ' Ready for transfer > > Shiftout IO, SCLK, LSBFIRST, [$bf] ' Read all 8 RTC > registers in burst mode > Shiftin IO, SCLK, LSBPRE, [rtcsec, rtcmin, rtchr, rtcdate, > rtcmonth, rtcday, rtcyear, rtccontrol] > > RST = 0 ' Reset RTC > Return > > ' Main program loop - in this case, it only updates the LCD with the > time > mainloop: > Gosub gettime ' Read the time from the RTC > > ' Display time on LCD > Serout lout,N9600,[254,1] ' Clear Display > 'Serout lout,N9600,[254,128,"hello"] > Serout lout,N9600,[254,128,#rtcmonth,"/",#rtcdate,"/",#rtcyear] > Serout lout,N9600,[254,192,#rtchr,":",#rtcmin,":",#rtcsec] > > Pause 300 ' Do it about 3 times a second > > Goto mainloop ' Do it forever > > End > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads