Maker Pro
Maker Pro

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

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...
 

Harald Kapp

Moderator
Moderator
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.
 
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.

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.
 

Harald Kapp

Moderator
Moderator
It may be a timing error when addressing the DS1307 which may lead to inadvertently clearing the RAM without you explicitly coding it.
 
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?
 

Harald Kapp

Moderator
Moderator
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
INTCONbits.GIE = 0
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.
 
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.
You mean like if INTCONbits.GIE = 1, then only will write data to the RTC RAM?
 

Harald Kapp

Moderator
Moderator
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.
 
Top