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


Sun Apr 30 2017, 05:49 AM
Lijin G Varghese
Can u send me the circuit diagram for Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
Sun Apr 30 2017, 05:48 AM
Lijin G Varghese
Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
Fri Apr 28 2017, 03:47 PM
I need pcb wizard 3.5 version kindly send valid link of yours
Fri Apr 28 2017, 03:46 PM
I need pcb wizard 3.5 version
Mon Apr 17 2017, 11:56 PM
Sorry..We had a problem with registration.Confirmation emails were not sent.Please re-register
Thu Apr 13 2017, 07:29 PM
Piyush Aughad
I want circuit & program for radar detection using Microcontroller 8051
Tue Apr 11 2017, 03:27 AM
Shabbir Ahmed
Hi Ajay ....hope you and your family all will be fine are you working on andriod aplications if yes then plz reply me
Sun Apr 09 2017, 06:33 PM
Dear Sir, I need to know what are the complexity for programming in 8051 Microcontroller for three phase inverter?
Sun Apr 09 2017, 06:32 PM
Dear Sir,
Sun Apr 09 2017, 04:43 AM
Rohit chandra joshi
Sir I need ur help urgently.i am trying to make pc controlled led scrolling display using 8051.when i am trying to generate hex file of the code that is given by pratik suthar.it gives the error Target not created Limit:0800h I am using keil uvision4 software. Even i have tried to burn the given hex file that is atteched with the code but my led are not glowing. Pls help me sir .i struck in this problem from last month and till now i am not able to short out the problem. Pls suggest me to solve the problem.mail me at [email protected] Thanks



Fri Apr 28 2017, 03:43 PM
Tue Apr 25 2017, 06:57 PM
Mon Apr 24 2017, 02:46 PM
Mon Apr 24 2017, 01:11 AM
Sun Apr 23 2017, 09:26 AM
Sun Apr 23 2017, 06:22 AM
Tue Apr 18 2017, 08:01 PM
Tue Apr 18 2017, 03:10 PM


Guests: 54, Members: 0 ...

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

Members: 37814
Newest member: anshulece
Forum Activity
Deepakvaishu Avatar
Posted By Deepakvaishu
Fri Apr 28 2017, 11:18 AM
Yes proteus is loaded ,with all projects.....Once ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Apr 28 2017, 05:06 AM
Does Proteus load at all ?Does it only crash on c...
Deepakvaishu Avatar
Posted By Deepakvaishu
Wed Apr 26 2017, 06:59 AM
hello...I am getting an error when I am trying to ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 18 2017, 10:52 PM
Thanks for the comment.Glad you got it working.
Deepakvaishu Avatar
Posted By Deepakvaishu
Tue Apr 18 2017, 06:19 AM
Thank you very much...Today I got the output for a...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 06 2017, 05:38 PM
Is it initially assigned as '0', and then when the...
Deepakvaishu Avatar
Posted By Deepakvaishu
Thu Apr 06 2017, 07:55 AM
hello,Thanks for the attachment.I have gone throug...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Mar 25 2017, 09:49 PM
I have attached code showing one method you could ...
Deepakvaishu Avatar
Posted By Deepakvaishu
Sat Mar 25 2017, 07:59 AM
I am using Keil and 8051 microcontroller
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Mar 24 2017, 06:05 PM
The best way is to use an interrupt to run the cou...