Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:16 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : RTC GETTIME....

     Page 1 of 2    
Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 12:37pm 28 Aug 2017
Copy link to clipboard 
Print this post

Hi folks.

MMBASIC 5.0405 on E64.

RTC GETTIME only gets the date - anyone seeing this?

What happens is that when I power-off a system using an RTC module(DS3231), the next day when I power-on, the date is correct, but the time is what it was when I powered it off yesterday - the time is out by hours and hours on what it should be.

RTC SETTIME works fine, so does RTC GETTIME, but it is odd because the time upon restart is NOT the current time, but rather the time that the system was powered off.
Even if somehow the system was updating the RTC at power-off, that would mean the time was still essentially correct at power-up if you see what I mean.

Really strange. Anyone got any ideas or seen anything like this before?
Have tried several different RTC modules - always the same.
To see this problem, you need to set the RTC, then power off for at least a couple of minutes to be able to 'See' the RTC error.
Smoke makes things work. When the smoke gets out, it stops!
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1044
Posted: 12:59pm 28 Aug 2017
Copy link to clipboard 
Print this post

Hi Grogs,

Have you searched your code for and unexpected TIME$= command.
Because it seems to know when it shut down is it anything to do with a VAR SAVE, VAR RESTORE thats sneaking in.

Regards
GerryEdited by disco4now 2017-08-29
F4 H7FotSF4xGT
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 05:22pm 28 Aug 2017
Copy link to clipboard 
Print this post

Not that I am aware of, but I will certainly search for that.

I might hook up the logic analyser to the I2C port and see if anything odd is going on at any point. I don't understand how the DATE is retrieved fine, but the time is not. Both require the participation of the RTC, and both are read together.
Smoke makes things work. When the smoke gets out, it stops!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 06:18pm 28 Aug 2017
Copy link to clipboard 
Print this post

Can't comment on 5.0405, but just checked the 64 pinner on a CGmicro2 & an E100,
both running on 5.04.04 & they are both working fine.

One thing I did notice in some code you posted in the last few days was,
[Code]Timer=0[/code]

in here

  Quote   '---------------
'MESSAGING MENU:
'---------------
MESSAGING:
If DEBUG then Print "Messaging menu."
CtrlVal(SM_TXT)="##ENTER MESSAGE HERE..."
PAGE 20,4 'Messaging and EXIT/OK buttons
If PROMPTING then
CHDIR "\SYSTEM"
PLAY WAV
"STAFF.NSF"
Endif
GUI Interrupt EXIT_OK
Timer=0:Y=0
Do
If LCD_EXIT then
LCD_EXIT=
0 'Clear flag
If DEBUG then Print "EXIT button touched.(send a message)"
Y=
1
Endif
If LCD_OK then
LCD_OK=
0 'Clear flag
If DEBUG then Print "OK button touched.(send a message)"
MSG$=
CtrlVal(SM_TXT)
SEND_PAGE(
"",MSG$,"[MANUAL MESSAGE>")
Y=
1
Endif
If Timer>=SSDELAY*2 then Y=1 'Auto-abort if no button touched.
If Y then EXIT Do
LOOP
ON Y GOTO START


Might be worth introducing a variable for the timeout like TouchTimer.

Just found I ended up painting myself into a few corners by resetting the timer in the code. Reset it in one place & then it broke things in other places that also relied on it counting from zero.

  Quote   '---------------
'MESSAGING MENU:
'---------------
MESSAGING:
If DEBUG then Print "Messaging menu."
..
..
GUI Interrupt EXIT_OK
TouchTimer=
Timer:Y=0
Do
..
..
..
If TouchTimer-Timer>=SSDELAY*2 then Y=1 'Auto-abort if no button touched.
If Y then EXIT Do
LOOP
ON Y GOTO START


Cheers


Phil.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 07:36pm 28 Aug 2017
Copy link to clipboard 
Print this post

REALLY?!?!?!

I would not have thought that the general-purpose timer would have any effect on the system clock at all, but perhaps.....

Geoff?
matherp?

I hear what you are saying Phil, but I would not have thought that the two could be connected. Can you please elaborate on some issues you were having with TIMER?
Smoke makes things work. When the smoke gets out, it stops!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:18pm 28 Aug 2017
Copy link to clipboard 
Print this post

  Grogster said  I would not have thought that the general-purpose timer would have any effect on the system clock at all, but perhaps.....


Sorry,

Should have added that there's no relation between the two;
Timer and Time$; distractions while commenting....

Only intended to point out the Timer resetting bit.

My only issue was with the Timer; as the spaghetti grew & found I was resetting it in to many places & some rests effected other areas.

Not at all related to the RTC.

PhilEdited by Phil23 2017-08-30
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 04:19am 29 Aug 2017
Copy link to clipboard 
Print this post

Okey dokey - thanks for that.
Smoke makes things work. When the smoke gets out, it stops!
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 11:12am 30 Aug 2017
Copy link to clipboard 
Print this post

Sure seems odd, hope you get an answer soon I haven't been able to sleep wondering what the answer is.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 02:11pm 30 Aug 2017
Copy link to clipboard 
Print this post

Yeah, it's still going on. I have no idea what could possibly cause this, because the DATE is correctly updated from the RTC at power up, but the TIME is not.

Now, that is REALLY odd, because the date AND time are both read from the RTC at the same time, in the same instruction, so if one works(the date), then the other should automatically also work(the time) - but it does not.

I have more RTC modules coming. I will try another couple and see if perhaps I just had a couple of crook ones. The ones I am using, I found rolling around in a box of modules, but the new ones will be sealed so perhaps the old ones got static damaged or something - who knows at this point.

EDIT: I just used MMEDIT to search for any instance of "TIME$=" in the code, which would find me any line where I might have been setting the time in the code that I had forgotten about - zero results, so I am not doing that anywhere. I will wait and see what the new RTC modules do.Edited by Grogster 2017-09-01
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 11:45pm 04 Sep 2017
Copy link to clipboard 
Print this post

Some new RTC modules have arrived, and trying one of these seems to produce the goods.
I have binned the other two to be sure that they won't get back into circulation.
Smoke makes things work. When the smoke gets out, it stops!
 
mikeb

Senior Member

Joined: 10/04/2016
Location: Australia
Posts: 177
Posted: 11:57am 05 Sep 2017
Copy link to clipboard 
Print this post

@All,

I guess that is to be expected of cheap, Chinese, knockoffs.
Try buying the genuine, Maxim, device from a reputable supplier.
5 times the price of the entire module. A case of "You get what you pay for".

Regards, Mike B.
There are 10 kinds of people in the world.
Those that understand binary and those that don't.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 01:47pm 05 Sep 2017
Copy link to clipboard 
Print this post

Yes, I know that, and I will accept any and all scolding - WhiteWizzard normally chimes in about now.......

I designed the mainboard to accept that particular module, which is perhaps one of the smallest RTC's you can get, but....

I guess I could probably 'Grogster-ify' the Chinese ones, by removing the clone chip and putting a genuine chip on there so it would still fit in the tiny footprint, but then be running a genuine part.
Smoke makes things work. When the smoke gets out, it stops!
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 02:49pm 08 Sep 2017
Copy link to clipboard 
Print this post

  mikeb said   @All,

I guess that is to be expected of cheap, Chinese, knockoffs.
Try buying the genuine, Maxim, device from a reputable supplier.
5 times the price of the entire module. A case of "You get what you pay for".

Regards, Mike B.


Means you can junk 4 of them and still be ahead!

Out of interest, which particular RTC module are you using Grogster? Got a link?

Cheers,

GTG!
...... Don't worry mate, it'll be GoodToGo!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 06:23pm 08 Sep 2017
Copy link to clipboard 
Print this post

Sure do, follow this link:

Small RTC module with on-board battery

What I like about these ones, is that they are DS3231(cloned at that price!), on-board backup battery, and they are very small physically, so they are easy to shoe-horn into a tight space if you are running low on PCB real-estate.

.....and I usually am by the time I think of adding an RTC!
Smoke makes things work. When the smoke gets out, it stops!
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 08:45pm 08 Sep 2017
Copy link to clipboard 
Print this post

I guess you have tried checking/replacing the backup battery(s) (?),
if there is some residual capacity it might run briefly and then lose it
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1013
Posted: 09:38pm 08 Sep 2017
Copy link to clipboard 
Print this post

Grogster, it is interesting that the link to the supplier shows the sales history and I see that a New Zealander bought 5 units on 25/08/2017. Going to own up?
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 11:38pm 08 Sep 2017
Copy link to clipboard 
Print this post

I have 4 of these units (fleabay) and they all work ok... odd
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9750
Posted: 03:08am 09 Sep 2017
Copy link to clipboard 
Print this post

@ OA47 - No. Well, OK - yes.
Smoke makes things work. When the smoke gets out, it stops!
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 02:44pm 09 Sep 2017
Copy link to clipboard 
Print this post

Those modules look handy, will have to grab a few, say 5, then throw 4 out.

Never played with aliexpress, is it similar to ebay? Can Paypal be used or should I get a prepaid Visa card?

GTG!


...... Don't worry mate, it'll be GoodToGo!
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2971
Posted: 10:12pm 09 Sep 2017
Copy link to clipboard 
Print this post

Hi Grogs, All,

They are the same as the ones I posted back in August 2015.
I posted that it was almost a drop in for my MuP PCB (Just needed 1 10mm link wire.)

Forum Link Here

I have used around a dozen of them and never had an issue with them, The seem pretty accurate and to date I haven't had a battery go flat.


Kind Regards,

MickEdited by bigmik 2017-09-11
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025