Hi Jeff,
Give this a shot. I've tested it on a 16F627A, and it works fine.
You can compare this to your original to see where I made the few changes.Code:DEFINE DEBUG_REG PORTB DEFINE DEBUG_BIT 7 DEFINE DEBUG_BAUD 19200 DEFINE DEBUG_MODE 0 ' 1 = inverted, 0 = true ' DS1307 control pins SDA VAR PORTB.1 ' DS1307 SDA pin #5 SCL VAR PORTB.2 ' DS1307 SCL pin #6 TRISA = %11111111 LeftButton var PORTA.1 ' Control Button RghtButton var PORTA.2 second var byte minute var byte hour var byte tock var byte CMCON = 7 ' all digital - comparators disabled PAUSE 1000 ' Allow power to stabilize on power-up GOSUB Blink_1200 ' Blink 12:00 time on entry Tick: gosub Read_1307 ' Read the time from the DS1307 Clock tock = second // 2 ' Get the Mod of second If tock = 0 then High PORTB.0 ' Turn on LED connected to PORTB.0 DEBUG "P",12,"~" ' Turn on colon else Low PORTB.0 ' Turn off LED connected to PORTB.0 DEBUG "P",0,"~" ' Turn off colon endif ' Display time DEBUG "D",hour DIG 1,hour DIG 0,minute DIG 1, minute DIG 0 PAUSE 1000 Goto Tick ' Go back to Tick Read_1307: ' Read time Seconds,Minutes,Hours I2CREAD SDA,SCL,$D0,$00,[second,minute,hour] ' Read time from DS1307 return Write_1307: ' Set time to 12:00 I2CWRITE SDA,SCL,$D0,$00,[$00,$00,$0C,$01,$01,$01,$00,$90] ' Write to DS1307 RETURN ' Sec Min Hr Day D M Y Control Blink_1200: ' Write 12:00 on display DEBUG "D",1,2,0,0 DEBUG "P",12,"~" ' Turn on colon pause 1000 DEBUG "C","~" ' Clear Display DEBUG "P",0,"~" ' Turn off colon pause 1000 if LeftButton = 1 then gosub Write_1307 'goto Tick return endif Goto Blink_1200 End




Bookmarks