-
Pic16f887 vs ds1307
IM USING SERIAL LCD TO DISPLAY ONLY SECOND...WHY MY LCD ALWAYS DISPLAY 20 IN HEX....
INCLUDE "modedefs.bas"
DEFINE OSC 20
DEFINE I2C_SLOW 1
TRISC = %00000000
TRISD = 0
SDA var PORTC.5
SCL var PORTC.3
Hours var Byte
Minutes var Byte
Seconds var Byte
RTC var Byte
I2C_Adr_B var byte
RTC = %11010000 ' Device adress on I2C bus
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[128,0,0,0,0,0,0,128] 'Reset time to 0 and stopped, 12 hour setting
PAUSE 100
gOSUB Start_RTC
PAUSE 900
SEROUT PORTD.1,N2400,[27,"1"]
PAUSE 50
SEROUT PORTD.1,N2400,[27,"P",$80,"TIME :"]
MAIN:
PORTD.2 = 1
GOSUB RTC_Read
PAUSE 100
sEROUT PORTD.1,N2400,[27,"P",$C5]
SEROUT PORTD.1,N2400,[27,"M",Seconds]
GOTO MAIN
Start_RTC:
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[0,0,0,0,0,0,0,16] 'Start RTC if you put a resistor and LED between the "SEC" pin and 5V it should start flash 1/s
return
RTC_Read:
I2C_Adr_B=0
I2CREAD SDA,SCL,RTC,I2C_Adr_B,[seconds,minutes, hours] ' in bcd code
return
END
-
Maybe this will work?
After you read the RTC.
Code:
SEC_T = seconds & $70
SEC_T = SEC_T>>4
Serout2 PORTC.6, 16572,["SEC_T ",DEC SEC_T, $d, $a]
-
Good pickup there is no decoding the RTC output.
The value displayed as it is shouldn't be the same every second though.
-
I don't why my second not counting...????.
-
There might be a hardware problem.
I would try turning on the square wave output on the RTC chip (if it has one),
Then you can see with an LED or scope that the chip is working at least.
You'll have had to talk to it correctly to set the pulse as well.