Thanks once again for your input to my posts.
Here's my basic code.
The strange thing is that even if I remove the DS1307 from the breadboard and connect the SDA wire to the junction of the 4.7K pull up resistor (ie as if the SDA line was being pulled high) the LCD displays 10:10.Code:ASM __CONFIG _CONFIG1H, _OSC_HSPLL_1H __CONFIG _CONFIG2L, _PWRT_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM DEFINE OSC 48 ; config settings 18F4580, 20mhz crystal ADCON1 = $0F clear DEFINE LCD_DREG PORTB ' LCD Data port DEFINE LCD_DBIT 0 ' starting Data bit (0 or 4) DEFINE LCD_EREG PORTB ' LCD Enable port DEFINE LCD_EBIT 5 ' Enable bit (on EasyPIC 5 LCD) DEFINE LCD_RSREG PORTB ' LCD Register Select port DEFINE LCD_RSBIT 4 ' Register Select bit (on EasyPIC 5 LCD) DEFINE LCD_BITS 4 ' LCD bus size (4 or 8 bits) DEFINE LCD_LINES 4 ' number of lines on LCD DEFINE LCD_COMMANDUS 2000 ' Command delay time in us DEFINE LCD_DATAUS 50 ' Data delay time in us RTCSec var byte ' Seconds RTCMin var byte ' Minutes RTCHour var byte ' Hours RTCWDay var byte ' Weekday RTCDay var byte ' Day RTCMonth var byte ' Months RTCYear var byte ' Year RTCCtrl var byte ' Control SetTime var byte ' 12/24 Hour Clock SetSec var byte ' Seconds SetMin var byte ' Minutes SetHour var byte ' Hours SetDay var byte ' Day SetMonth var byte ' Months SetYear var byte ' Year RTCSec = 0 RTCMin = 1 RTCHour= 2 RTCWDay =1 RTCDay =1 RTCMonth=10 RTCYear =13 RTCCtrl =0 Counter1 var byte counter2 var byte counter3 var word CounterA var byte ' General purpose Variable TimeH var byte ' Variable to store current hour TimeM var Byte ' Variable to store current minutes '**************************************************************** CCP1CON = %00001100 ' CCP2CON = %00001100 '**************************************************************** 'DS18B20 setting DQ VAR PORTA.5 ' One-wire data pin temperature VAR WORD ' Temperature storage count_remain VAR BYTE ' Count remaining count_per_c VAR BYTE ' Count per degree C '**************************************************************** 'analog settings ADCON0 = 0 'Set ADCON0 ADCON1 = %00001111 'Set D i/o CMCON = 7 'Disable Comparators '**************************************************************** 'Port settings CCP1CON = %00001100 ' CCP2CON = %00001100 ' TRISA = %11101111 ' TRISB = %00000011 TRISC = %00011011 TRISD = %00000011 ' SCLpin var PORTC.3 ' RTC pin - clk SDApin var PORTC.4 ' RTC pin - data Main: I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl] timeH=(RTCHour>>4) 'convert the BCD format of the hours register and store in variable timeH timeH=(timeH &$03)*10 timeH=timeH+(RTCHour&$0F) timeM=(RTCMin>>4) timeM=(timeM &$07)*10 timeM=timeM+(RTCMin&$0F) 'convert the BCD format of the mins register and store in variable timeM If TimeH = 0 and timeM = 0 then Counter3 = 0 endif If TimeH <0 then Counter1 = 0 endif If timeH >0 then Counter1 = TimeH * 60 endif lcdout $FE,$80,"Counter 3 = ",dec Counter3 I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl] If RTCHour.6=1 then CounterA=(RTCHour>>4)&$01 ' Work-Out 12 or 24 hour Display for Hours else CounterA=(RTCHour>>4)&$03 endif CounterA=CounterA*10+(RTCHour&$0F) ' Display Hours appropriately for 12 or 24 hour Mode If RTCHour.6=1 then LCDOut $FE,$D4,#CounterA else LCDOut $FE,$D4,#CounterA Dig 1,#CounterA Dig 0 endif LCDOut ":",#(RTCMin>>4)&$0F,#RTCMin&$0F," " Counter3 = counterA*60 + TimeM GOTO Main
I've also tried code that is running in my current LED lights (for fish tank) using the same chip. This also displays the same issue with the breadboarded chip, but if that chip is removed and placed back in the light controller it picks up the 1307 and displays the current time.
I'll look at the links and see what develops
Malcolm




Bookmarks