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

rawat742
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 01:45 PM
angel patel
hey any one help to make the led scrolling display
desuza6
Sat Jul 29 2017, 07:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
rammichael
Thu Jul 27 2017, 12:05 PM
okay fine
ExperimenterUK
Wed Jul 26 2017, 07:51 PM
Please post questions in the forum, the chat box is for chat
msd007
Wed Jul 26 2017, 11:27 AM
i need code if any one have aduc706 interfacing lcd 16*2
msd007
Wed Jul 26 2017, 11:26 AM
pl help me how to write code of interfacing ADuc7026 controlleo lcd pl any one help me hoe to initializend configure the direction
rammichael
Wed Jul 26 2017, 06:04 AM
can you explain what is timer and how to use their modes ...
rammichael
Wed Jul 26 2017, 06:03 AM
ExperimenterUk thank you for your quick reply okay

Downloads

Comments

kira113
Sat Aug 19 2017, 08:40 AM
Pirateak
Thu Aug 17 2017, 02:02 PM
sathishksk71
Wed Aug 16 2017, 04:47 AM
rawat742
Sun Aug 13 2017, 05:49 PM
alparslanbagriyanik
Fri Aug 11 2017, 08:10 AM
Thanhquan
Sat Aug 05 2017, 05:17 PM
NAMRATHA
Thu Aug 03 2017, 08:32 AM
Kgj
Tue Aug 01 2017, 12:41 PM

Online

Guests: 92, Members: 0 ...

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

Members: 37879
Newest member: kira113
Forum Activity
kira113 Avatar
Posted By kira113
Sat Aug 19 2017, 08:52 AM
hello everyone i write a simple program using c la...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Aug 19 2017, 02:47 AM
else x+=0x46; //print as ascill 0x41 to 0x46 A-F ...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 02:58 PM
Dear Sir, I have a another program in which I am a...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:45 AM
LCD SCROLLING MESSAGE PROGRAM CODE AND SIMULATION...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:24 AM
Dear Sir , I am not able to increased value by pre...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:19 AM
Dear Sir, as per your attachment I w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Aug 17 2017, 10:54 PM
Try this. Attachment ...
rawat742 Avatar
Posted By rawat742
Thu Aug 17 2017, 08:24 PM
Dear Sir , Please help me for stor...
sathishksk71 Avatar
Posted By sathishksk71
Wed Aug 16 2017, 04:53 AM
Hi.. Iam refreshing c language using this useful r...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 14 2017, 10:19 PM
The original 8051 is a primitive device.Over the ...