Discussion in "Project Doubts" started by    JaguarPaw    Dec 12, 2016.
Mon Dec 12 2016, 09:43 PM
I have used the I2C library and followed the tutorial.
I am using a DS1307 and a PIC16f1829 with the xc8 compiler.

I have pull up resistors

About 7/10 times i attempt to read the DS1307 it gets stuck here while(!SSP1STATbits.BF);
in the read routine.
I have had succesfull reads be as mentioned before only about 3/10 times.
Tue Dec 13 2016, 08:52 AM
can you post your code snippet? are you calling with NAK at last byte read?
 JaguarPaw like this.
Fri Dec 16 2016, 02:33 PM
while (1)
I2CStart ();
r = I2CRead();

for (i = 8; i > 0; i--)
/* read a byte */
I2CData[i] = I2CRead();

if (i - 1)
/* Send stop */


the r variable would successfully store the number returned back from the ds1307 as it was originally working
now it will freeze where i stated before or return null

here is the set up code. the subroutines are the same as on this website.
void main(void)
// Oscillator configuration

// SCS FOSC; SPLLEN disabled; IRCF 8MHz_HF;
OSCCON = 0x70;
// LFIOFR disabled; HFIOFL not stable; OSTS intosc; PLLR disabled; HFIOFS not stable; HFIOFR disabled; MFIOFR disabled; T1OSCR disabled;
OSCSTAT = 0x00;
// TUN 0;
OSCTUNE = 0x00;
// Set the secondary oscillator

// Wait for PLL to stabilize
while(PLLR == 0)

// Pin configuration

TRISBbits.TRISB4 = 1;
TRISBbits.TRISB6 = 1;
//SSP1STATbits.SMP = 0;

SSP1STAT = 0x80;
// SSPEN enabled; WCOL no_collision; CKP Idle:Low, Active:High; SSPM FOSC/4_SSPxADD_I2C; SSPOV no_overflow;
SSP1CON1 = 0x28;
// ACKTIM ackseq; SBCDE disabled; BOEN disabled; SCIE disabled; PCIE disabled; DHEN disabled; SDAHT 100ns; AHEN disabled;
SSP1CON3 = 0x00;
// Baud Rate Generator Value: SSPADD 79;
SSP1ADD = 0x4f;
Wed Dec 21 2016, 09:07 PM
Have you made any progress ?

It sounds as if your hardware is on the edge of working /not working.
What pull up resitors are you using ?
Do you have a good ,clean power supply and good ground connections between the
PIC and the 1307.

If you power off the board each time , and stop after the first read (r = I2CRead();)
how reliably does it read ?

Get Social


Powered by e107 Forum System


Wed Mar 22 2017, 09:13 PM
ajay kumar
help me nokia lcd light
Wed Feb 22 2017, 06:14 AM
Indeed, on the LCD tutorial, many missing Tables and figures !!
Wed Feb 22 2017, 06:06 AM
I don't see any Table 3. I'm using Chrome.
Fri Feb 03 2017, 05:56 AM
irfan shaikh
hi, i want interface WS2811 pixel led using NUVOTON N79E352, but i dont know how to code it. can anyone help me or provide me sample coding for interfacing WS2811 PIXEL LED. THNX
Thu Jan 19 2017, 08:42 PM
Hi...i have made a circuit for interfacing PT100 with LM358 whose temperature is shown on the LCD...But the temperature is not getting incresed slowly ..a small change directly increses the temp...can any one help me
Thu Jan 19 2017, 04:27 PM
send me alarm clock simulation using proteus software
Mon Jan 16 2017, 03:15 PM
How can we read notepad file using random acess file
Fri Jan 06 2017, 06:18 AM
muhammad Umar
i need cd4047 library file for protious please help me i s
Wed Jan 04 2017, 09:01 PM
@Emin what is your site user name ?
Tue Jan 03 2017, 11:16 PM
Emin: I'm already a member since 2012 and entered repeatedly during period. But now it is impossible and obtaining a new registration is also failed. The same error message specifying that two e-mails i entered are different!. In fact thaey are the same. Now, what will be happen, what is your solution? Thanks..



Tue Mar 21 2017, 02:29 PM
Mon Mar 20 2017, 11:21 AM
Tue Mar 14 2017, 07:08 AM
Wed Feb 22 2017, 02:40 AM
Thu Feb 16 2017, 02:40 PM
Thu Feb 09 2017, 09:59 AM
Sat Jan 28 2017, 08:58 AM
Tue Jan 17 2017, 06:25 PM


Guests: 75, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37804
Newest member: SAUnwin
Forum Activity
Deepakvaishu Avatar
Posted By Deepakvaishu
Fri Mar 24 2017, 05:22 AM
Hi,I got that we should use timer......But I am a ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Mar 23 2017, 09:14 PM
You have largely answered your own question.Use on...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Mar 23 2017, 07:03 AM
I have looked at your code.I think you are confuse...
Deepakvaishu Avatar
Posted By Deepakvaishu
Thu Mar 23 2017, 05:34 AM
hello,I can type the letters now when the particul...
SAUnwin Avatar
Posted By SAUnwin
Tue Mar 21 2017, 02:55 PM
HI,There are two ways I'd tackle thiss.Key down on...
Deepakvaishu Avatar
Posted By Deepakvaishu
Mon Mar 20 2017, 08:24 AM
hello,I am using a keypad to type the text message...
Helia Avatar
Posted By Helia
Thu Mar 16 2017, 09:15 AM
hi.. the following code is not working on hardware...
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Mar 14 2017, 08:39 AM
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Mar 14 2017, 08:36 AM
Try to check the character set currently set in yo...
Deepakvaishu Avatar
Posted By Deepakvaishu
Thu Mar 09 2017, 05:14 AM
sim 300 gsm modem is not able to send the message ...