View previous topic :: View next topic |
Author |
Message |
pyu
Joined: 04 Feb 2009 Posts: 51
|
i2c_start() fail |
Posted: Wed Apr 24, 2013 2:14 am |
|
|
Hello.
I have a pickit2 with 16f887 and ds1307.
I used this hardware last time in 2009.
Now, isn't working any more.
Code: | void ds1307_init(void)
{
BYTE seconds = 0;
i2c_start();
...
} |
Somehow, it creating a infinite loop here (I made a debug), it's never pass from this line:
What can be the problem for this? Any ideas?
Thanks. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Wed Apr 24, 2013 5:27 am |
|
|
some ideas...
...assuming the PIC will run a '1Hz blinking LED program
1) no battery on the 1307 ?
2) no I2C bus pullups ?
3) download PCM programmer's I2C 'scanner test program' and see what happens.
If code was working, logic says it's a hardware problem..
hth
jay |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Wed Apr 24, 2013 6:00 am |
|
|
temtronic wrote: | some ideas...
...assuming the pIC will run a '1Hz blinking LED program
1) no battery on the 1307 ?
2) no I2C bus pullups ?
3) download PCM programmer's I2C 'scanner test program' and see what happens.
If code was working, logic says it's a hardware problem..
hth
jay |
Thanks for your fast response.
1 - maybe battery is dead. will try another battery. current one is there since 2009, when I worked last time with my pickit2.
2 - I have those 2 resistors. it worked last time in 2009.
3 - where can I find this scanner test program?
Thanks! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Apr 24, 2013 6:13 am |
|
|
Quote: | 3 - where can I find this scanner test program? |
Do a search on this forum
Search for keyword "i2c"
Search for author "PCM programmer"
Set search for ALL terms
Mike |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Wed Apr 24, 2013 1:06 pm |
|
|
I made a test, it crashes on this line:
Code: | status = i2c_write(address); // Status = 0 if got an ACK |
I replace the battery, same problem :( |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 24, 2013 2:28 pm |
|
|
Look at the SCL clock line with an oscilloscope. Is it stuck at a low level ?
If so, verify that the pull-up resistor is really connected. Make sure
the ds1307 has power. Remove the ds1307 from the circuit to see
if the test program still locks up. |
|
|
pyu
Joined: 04 Feb 2009 Posts: 51
|
|
Posted: Thu Apr 25, 2013 2:24 am |
|
|
Hi.
I re-soldered all the wires and resistors, and now it's working
Thanks. |
|
|
|