Connect with us

How come the value in my RAM of DS1307 RTC become zero?

Discussion in 'Microcontrollers, Programming and IoT' started by maniac84, Oct 13, 2014.

Scroll to continue with content
  1. maniac84

    maniac84

    7
    0
    Jun 19, 2013
    Hi guys... I'm using the 56 bytes of RAM in the DS1307 to store some data. My DS1307 is connected to the PIC18F46K22. But after running a few days, all the data inside the RAM will suddenly become zeros. The time in the RTC is still accurate but it's just that all the data in the RAM has become zero. I have check my coding but cannot pin point what's the problem. Do you guys have any idea? I did not reset it to zero from my coding...
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,893
    2,096
    Nov 17, 2011
    If your coding really does not contain any bug that resets the RAM, the only way I see for the RAM to be cleared is a very short interruption of the power supply. Although in this case I'd expect the clock to malfunction, too. Therefore chances are that it is a bug in your software.
    Is a backup battery in place? Is it fresh?
    If no backup battery is being used, Vbat needs to be grounded.
     
  3. maniac84

    maniac84

    7
    0
    Jun 19, 2013
    Yes, there is a backup battery 3V. But like you say, if the backup battery failed, the date and time of the RTC should be effected too right? But now it just that the data in the 56 bytes RAM is getting reset to zero, the date and time is still accurate.
    Anyway, if it is a coding bug, how does it look like? Because in the coding, I did not reset the data to zero.
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,893
    2,096
    Nov 17, 2011
    It may be a timing error when addressing the DS1307 which may lead to inadvertently clearing the RAM without you explicitly coding it.
     
  5. maniac84

    maniac84

    7
    0
    Jun 19, 2013
    Could you explain more? How do timing error when addressing the DS1307 happen?
     
  6. maniac84

    maniac84

    7
    0
    Jun 19, 2013
    Is there any possibilities that during the time when data is written to the RAM, there is some interruption from the ISR? I got put a timer in the ISR.
    Do we need to put INTCONbits.GIE = 0; when data is written to the RTC RAM?
     
  7. Harald Kapp

    Harald Kapp Moderator Moderator

    9,893
    2,096
    Nov 17, 2011
    I'm not into PIC details, so don't expect any statements about which bits to set or not.
    On a general note, however, it may be a good idea no to interrupt write accesses to the DS1307.
    If
    this is the way to do it.

    There is also a note in the datasheet: "WARNING: Negative undershoots below -0.3V while the part is in battery-backed mode may cause loss of data. "

    This may be an issue, too.
     
  8. maniac84

    maniac84

    7
    0
    Jun 19, 2013
    You mean like if INTCONbits.GIE = 1, then only will write data to the RTC RAM?
     
  9. Harald Kapp

    Harald Kapp Moderator Moderator

    9,893
    2,096
    Nov 17, 2011
    I mean:

    - disable interrupt
    - write to NVRAM
    - enable interrupt

    I don't know which bits need to be set or reset in a PIC to disabel or enable interrupts.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-