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


Mon Aug 05 2019, 08:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 05:33 PM
Ismail balghmi
Hello. Please I won't download
Wed Jul 24 2019, 01:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 07:13 PM
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
Thu Jul 11 2019, 08:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html
Thu Jul 11 2019, 08:44 PM
@praveen123. Can you give a link to the project ?
Thu Jul 11 2019, 05:47 PM
buenos dias alguien podria ayudarme necesito saber como descargar la libreria del l298n para proteus
Thu Jul 11 2019, 12:11 PM
anyone can help me
Thu Jul 11 2019, 12:11 PM
i need source code for 8051 -smart trolley rfid
Thu Jul 11 2019, 12:10 PM



Sat Aug 17 2019, 03:41 AM
Wed Aug 07 2019, 10:35 AM
Sat Aug 03 2019, 01:16 PM
Mon Jul 29 2019, 07:39 AM
Wed Jul 24 2019, 04:44 AM
Sun Jul 21 2019, 12:41 AM
Fri Jul 19 2019, 11:31 AM
Fri Jul 19 2019, 07:36 AM


Guests: 46, Members: 0 ...

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

Members: 38086
Newest member: jualanled
Forum Activity
nick@IT Avatar
Posted By [email protected]
Wed Aug 07 2019, 10:38 AM
I am trying to execute USSD codes through my GSM m...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Jul 28 2019, 08:55 PM
An LM339 may not be fast enough for reliable SPI ...
sakibnaz Avatar
Posted By sakibnaz
Sun Jul 28 2019, 06:40 AM
Hi All.I need to connect my MCU with an external S...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jul 24 2019, 10:42 PM
Your unit is communicating, so I assume the GPS si...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jul 24 2019, 10:32 PM
Have you read this ?http://www.8051projects.net/wi...
manu8193 Avatar
Posted By manu8193
Wed Jul 24 2019, 04:57 AM
any one tell me the explaination and 'c' code for ...
3AAPC Avatar
Posted By 3AAPC
Sun Jul 21 2019, 12:51 AM
3AAPC Avatar
Posted By 3AAPC
Sun Jul 21 2019, 12:47 AM
With the GPS antenna in the outdoors, I use the ub...
ameya123 Avatar
Posted By ameya123
Fri Jul 19 2019, 07:42 AM
Hello,Please share 8051 Assembly language code for...
figureyang Avatar
Posted By figureyang
Fri Jul 05 2019, 04:37 AM
here is the source code prepared for you download ...