12C fails on first attempt, then works fine...


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    70

    Default 12C fails on first attempt, then works fine...

    I'm trying to communicate with a Micro Crystal RV-1805-C3 real time clock using a PIC12LF1840. This RTC has a high impedance pin that can be employed to switch off everything but the clock and then power everything back up again when needed. So you can get a super low sleep current for the system (like 20 nA).

    When the PIC powers up, the first thing I want it to do is read parameters from the clock on an I2C bus. I've found through experimentation that the first attempt to communicate with I2C consistently fails both for reading and writing. After that it works fine. I've tried adding things before the first I2C communication such as long pauses and simulated stop conditions, but they have no effect. There are two things that seem to work. First is just to insert a dummy I2C command addressed to a non-existing device (or just issue a read to the clock and ignore the results). Second is to have the clock implement a brief delay before it shuts down the PIC. That is, you have the clock wait for a period of 8ms after the last I2C command before shutting things down. Somehow this wait period enables the PIC to wake up and do I2C coms as usual. I have no idea why. I just have a pause following the go-to-sleep command to the clock.

    Ideally I would like to have this system minimize its awake time. It's not a huge deal to have the dummy I2C command as a work around, but I would still like to understand what's going on. I haven't scoped the I2C lines yet, but I could if this this stumps the forum.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: 12C fails on first attempt, then works fine...

    birg0030, Do you have the requisite resistor pull-ups on the SCL and SDA lines?
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: 12C fails on first attempt, then works fine...

    Quote Originally Posted by Dave View Post
    birg0030, Do you have the requisite resistor pull-ups on the SCL and SDA lines?
    I have 22K pull-ups in place. I know that value is a bit high, but slowing down the transmission rate does not help.

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 12C fails on first attempt, then works fine...

    I'm no expert, and don't understand the formula outlined in the datasheet http://www.ti.com/lit/an/slva689/slva689.pdf but it seems to suggest that lower value resistors are required. The example given for fast transmission at 3.3v is typically 1K, or around 5K (4.7K are traditionally the norm) for 5v operation

  5. #5
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: 12C fails on first attempt, then works fine...

    I don't think it is the resistors. I've used 100k before and it's been OK. I also tried different values in parallel with the 22k resistors to bring the pullup values down. Issue remains.

    I've done some more tweaking and I don't seem to have the same problem with two other I2C devices on the same bus. So the issue might be something particular to the RTC.

Similar Threads

  1. Replies: 8
    Last Post: - 6th February 2014, 19:36
  2. Replies: 1
    Last Post: - 23rd May 2009, 10:22
  3. 7805 works fine, LM2940CT5 not!
    By DanPBP in forum Off Topic
    Replies: 4
    Last Post: - 29th August 2007, 23:01
  4. ERROR Compling 16F819...l but the 16F818 works fine
    By 4Lewis in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st April 2006, 07:47
  5. 12c or SPI which is faster?
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th July 2004, 02:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts