Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem of RTC remaining information

Status
Not open for further replies.

andy40185

Member level 5
Joined
Sep 30, 2011
Messages
80
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,810
My rtc(DS1307) cannot remain the information(either date or time). I have connected the 3V Li-battery to pin3(vbat) and 5v to pin8(Vcc) together.
When I disconnect the 5v supply and then re-connect it, the rtc only starts to which I set to. Why happens this issue??
 
Last edited:

Not much info there (such as the RTC model, circuit diagram) but if (as you say) it is starting at the value to which you set it to,
then that points to a code issue (you shouldn't be setting the value after microcontroller reset).
 

Not much info there (such as the RTC model, circuit diagram) but if (as you say) it is starting at the value to which you set it to,
then that points to a code issue (you shouldn't be setting the value after microcontroller reset).
Is you mean that it is no longer setting the information after I have set the information for one time? (The information has been stored in rtc when I set it one time??)

---------- Post added at 23:42 ---------- Previous post was at 23:39 ----------

Not much info there (such as the RTC model, circuit diagram) but if (as you say) it is starting at the value to which you set it to,
then that points to a code issue (you shouldn't be setting the value after microcontroller reset).
Is you mean that it is no longer setting the information after I have set the information for one time? (The information has been stored in rtc when I set it one time??)
 

I'm just saying you only need to set the RTC once. If after power loss the time is still the same value that you set it to and has not increased,
then it is likely that your code is reprogramming the RTC once the power is reconnected. I could be wrong. But worth checking out anyway.
 

If you have connected a separate battery to the Vbat pin,then you must initialize the rtc in your code only once.In your case,the code is initializing the rtc value every time it is powered up through the Vcc pin.
Initialize the rtc only once on power up and develop some logic to skip the initialization code during subsequent runs through the code.
This will surely solve your problem.....

---------- Post added at 21:50 ---------- Previous post was at 21:49 ----------

If you have connected a separate battery to the Vbat pin,then you must initialize the rtc in your code only once.In your case,the code is initializing the rtc value every time it is powered up through the Vcc pin.
Initialize the rtc only once on power up and develop some logic to skip the initialization code during subsequent runs through the code.
This will surely solve your problem.....
 

?Initialize the rtc only once on power up I do not understand this. Do I comment the initialization of rtc after the rtc has been initialized once ?
Also, please refer to the following code,,,

Code:
void System_init(void)
{
        lcd_init();
	s_connectionreset();
	DS1307_settime(0x10,0x40,0x30);
	DS1307_setdate(0x15,0x05,0x12);	
}
 
Last edited:

Your battery backup is for the rtc, _not_ the microcontroller. So, after the circuit is restarted, then the microcontroller will rerun the
system_init() function that you've shown. So since you're executing the settime() function, it explains the problem you're experiencing.
Line Anish says, you need to implement some scheme not to execute this each time the microcontroller reboots. For example - only execute
the function if a specific switch is pressed.
 

To all,

I have tested that the problem could be solved when commenting both DS1307 setting function.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top