tried that already. It doesn't help.
What do you mean by "the I2c read and write address/control string have to be different" ?
tried that already. It doesn't help.
What do you mean by "the I2c read and write address/control string have to be different" ?
RTCADW CON %11010000 'DS1307 RTC ADDRESS SEND...RECEIVE
RTCADR CON %11010001
I2CWRITE SDA,SCL,RTCADW,7 ,%00010011 'TURN ON SQU WAVE OUT 32k HZ
I2CREAD SDA,SCL,RTCADR,0,[RTC[1],RTC[2],RTC[3],RTC[4],RTC[5],RTC[6],RTC[7]]
from my rtc stuff
don
Ok, So I tried to use your example.
Still getting '0' when reading. If i use 10K resistors on the SDA and SCL I get '16'
Code:INCLUDE "modedefs.bas" RTC VAR BYTE[8] ' Data byte array RTCADW CON %11010000 'DS1307 RTC ADDRESS SEND...RECEIVE RTCADR CON %11010001 SDA var PORTC.4 SCL var PORTC.3 pause 1000 I2CWRITE SDA,SCL,RTCADW,7,%00010011 'TURN ON SQU WAVE OUT 32k HZ main: ;I2CREAD PORTC.4,PORTC.3,%11010000,$00,[RTCSec] I2CREAD SDA,SCL,RTCADR,0,[RTC[1],RTC[2],RTC[3],RTC[4],RTC[5],RTC[6],RTC[7]] SEROUT PORTC.6,6,[254,1] toggle PORTD.7 : pause 1000 SEROUT PORTC.6,6,[254,128,#RTC[1]] pause 1000 goto main
well,
data on 1307 is hex so.......
SEROUT2 PORTA.0,6,1,[ "_T" ,HEX RTC[6],"/",HEX2 RTC[5],"/20",_
HEX2 RTC[7]," , ",HEX RTC[3],":",HEX2 RTC[2],":",HEX2 RTC[1]," ",RTC[9],"M _" ]
( use your own port etc.)
the voltage on SCL & SDA (to gnd) has to be +5 at rest, no signal . Thats what the 10k resisters do.
also, you can check square wave out at 1 HZ with led/resister on the output pin of 1307 as visual check of rtc.
I2CWRITE SDA,SCL,RTCADW,7,%00010000 'TURN ON SQU WAVE OUT to...1... HZ
Last edited by amgen; - 28th June 2008 at 04:10.
PBP handles the R/W bit for you just like it says in the manual...so...
Code:INCLUDE "modedefs.bas" RTC VAR BYTE[8] ' Data byte array RTC CON %11010000 'DS1307 RTC ADDRESS SEND...RECEIVE SDA var PORTC.4 SCL var PORTC.3 pause 1000 I2CWRITE SDA,SCL,RTC,7,%00010011 'TURN ON SQU WAVE OUT 32k HZ main: I2CREAD SDA,SCL,RTC,0,[RTC[1],RTC[2],RTC[3],RTC[4],RTC[5],RTC[6],RTC[7]] SEROUT PORTC.6,6,[254,1] toggle PORTD.7 : pause 1000 SEROUT PORTC.6,6,[254,128,#RTC[1]] pause 1000 goto main
well,
I can't get any signal on the SWQE output, not by LED or by the logic analyzer of the PICkit2. So I might guess the 1307 is malfunctioning.
This is what I get when analyzing the SCL vs SDA
This is what I get when analyzing the SCL vs SWQ
This is what I get when analyzing the SCl vs SDA
Last edited by menta; - 28th June 2008 at 12:15.
Here are a few things that 'may' help;
1. If you're using an oscillator >8MHz, then you'll want to include DEFINE I2C_SLOW 1
since the 1307 max clock speed is 100kHz.
2. The SQW output is an open-drain type. I.E. it cannot output a logic 1. Use a 10K
pull-up on the SQW output. Then you should see a square wave output on your scope.
3. Use the external pull-ups on SDA and SCL.
4. Connect a 3V battery to the 1307 Vbat input.
Bookmarks