Discussion in "Project Doubts" started by    JaguarPaw    Dec 12, 2016.
Mon Dec 12 2016, 09:43 PM
#1
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
#2
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
#3
while (1)
{
I2CStart ();
I2CSend(0xD0);
I2CSend(0x00);
I2CRestart();
I2CSend(0xD1);
r = I2CRead();

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

if (i - 1)
I2CAck();
else
I2CNak();
}
/* Send stop */
I2CStop();

}
}

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

ANSELB = 0;
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
#4
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

Information

Powered by e107 Forum System

Conversation

ExperimenterUK
Thu Jan 11 2018, 06:23 PM
Hi Dave. Good to see you. Parole ?
DavesGarage
Wed Jan 10 2018, 12:55 PM
It's been a few years since I poked around here - Hi all...
ExperimenterUK
Tue Jan 09 2018, 12:19 PM
Hi TPS. it's been a while..
۞ TPS ۞
Mon Jan 08 2018, 11:42 AM
hello
Fri Jan 05 2018, 06:50 AM
sayyad affrid
its AT89S52
Fri Jan 05 2018, 06:50 AM
sayyad affrid
sir, i want embedded c code for ultrasonic sensor having buzzer interfaced with AT9S52
Tue Dec 19 2017, 01:12 PM
zafir
i am making digital voltmeter using AT89C51, ADC and LCD 16x2,,, kindly someone please send me hex file in assembly language
Sat Dec 16 2017, 05:18 AM
mehari
can not find dhtxx.md file in proteus 8.0 can anybody help me please?
sahar7478
Sat Dec 09 2017, 05:47 AM
can i get gsm a6 library? can anybody help? tia
Faiqa
Sun Nov 26 2017, 01:32 AM
Can i get the code of Monitering and controlling of green house effect? ... Can anyone help me ?

Downloads

Comments

eddieprice
Fri Jan 12 2018, 04:07 PM
bastik
Fri Jan 12 2018, 09:36 AM
cjj20
Tue Jan 09 2018, 07:29 PM
shahzadiqbal
Tue Jan 09 2018, 01:57 PM
shailu1809
Mon Jan 08 2018, 01:11 AM
saffrid97
Sun Jan 07 2018, 01:48 AM
vietbac
Sat Jan 06 2018, 10:08 AM
Pecman
Wed Jan 03 2018, 03:58 PM

Online

Guests: 52, Members: 0 ...

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

Members: 37943
Newest member: eddieprice
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Jan 13 2018, 10:26 PM
This is clearly an old design.A modern microcontr...
bastik Avatar
Posted By bastik
Sat Jan 13 2018, 09:38 PM
For now I don’t have much information about device...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jan 12 2018, 06:49 PM
Sometimes the Configuration word has to be program...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jan 12 2018, 06:30 PM
What exactly is your situation ?I very much doubt ...
eddieprice Avatar
Posted By eddieprice
Fri Jan 12 2018, 04:32 PM
I am using a 16F84A for the first time and am havi...
bastik Avatar
Posted By bastik
Fri Jan 12 2018, 10:37 AM
I have device with SAB80C535 microcontroller and I...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jan 12 2018, 12:01 AM
I tried to compile your 8051 version in Keil 5but...
cjj20 Avatar
Posted By cjj20
Tue Jan 09 2018, 07:42 PM
I just think something is off in the checkgpgga fu...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jan 09 2018, 07:35 PM
Why do you think there is something wrong with it...
cjj20 Avatar
Posted By cjj20
Tue Jan 09 2018, 07:32 PM
Please help me correct this code #include ...