Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:15 13 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 : Now this is weird

Author Message
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 04:35pm 02 Jul 2019
Copy link to clipboard 
Print this post

I have a microcontroller + RTC setup that works absolutely fine with power. I drop the power for an hour or two and it all works as expected when it comes back up.

Change that hour to eight or nine hours and the time from the RTC is "stuck" - it runs again but the time is a few hours old.

I am currently chasing down bit 7 of the status register to see if the clock is stopping while in power down or something else is happening (won't know until the morning) but just wondering if anyone else has seen this?

If the battery was failing I would expect it to go to "zeroes" but it is almost like the clock is going static - the registers are not being cleared... as if the battery voltage were dropping enough to stall the clock but then with reduced drain it is enough to maintain the registers... sounds like a long shot to me but I am currently away from home with no access to DMM, scope etc...

any clues?
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 12:34am 03 Jul 2019
Copy link to clipboard 
Print this post

  Quote  currently chasing down bit 7 of the status register to see if the clock is stopping


I think you are right. Had some fun with a RTC/fading backup coin cell which gave similar symptoms, ie the battery would kark, the oscillator stop, but the other registers would otherwise be ok. The cell voltage would then recover enough to run it for a while after it was restarted.
As you would know the bit which flags that the oscillator has stopped, has to be reset to start the oscillator, so I guess that is done by default by the micro when it starts. Maybe the few hours difference is from 12-hour overlap.

edit - maybe a local shop stocks the coin cell, but I remember it was a bit of a search to find the exact type. Edited by isochronic 2019-07-04
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 08:04am 03 Jul 2019
Copy link to clipboard 
Print this post

cheers isochronic. I think it must be a failing cell (not a rechargeable), but what a borderline situation.

Here is the bit of code that handles the RTC initialization so you can understand the output after it:


Print "Configuring CPU & RTC for MkII"
CPU 48 'cpu to maximum speed
'take the RTC out of store mode
RTC GetReg &h0E,n
Print "Register &H0E ";bin$(n,8)
RTC SetReg &h0E,n And &b00111111

'test the validity of the time
RTC GetReg &h0F,n
Print "Register &H0F ";bin$(n,8)
If n And &b10000000 Then
Print "NOTE: Internal RTC Oscillator has been stopped during power down."
RTC SetReg &h0F,0
EndIf


Here is the last time I powered it up (having had no problem all day with dark periods of about an hour or so apiece...


Micromite MKII MMBasic Ver 5.04.08
Copyright 2011-2017 Geoff Graham

0.481 System coming up.
Platform is Micromite MkII
Configuring CPU & RTC for MkII
Register &H0E 00000110
Register &H0F 00000000
Configuring working environment
Starting Main process
02-07-2019 16:40:40
Start Current Target
----------------------------------------------------
<snip>



and then after a night with no power ... 07:28 power re-applied.



Micromite MKII MMBasic Ver 5.04.08
Copyright 2011-2017 Geoff Graham

0.481 System coming up.
Platform is Micromite MkII
Configuring CPU & RTC for MkII
Register &H0E 00000110
Register &H0F 10000000
NOTE: Internal RTC Oscillator has been stopped during power down.
Configuring working environment
Starting Main process
03-07-2019 07:18:29
Start Current Target
----------------------------------------------------
<snip>



It is showing Reg 0F,bit 7 set thus reporting a stopped oscillator and I only caught it by 10 minutes(!?) doesn't sound very likely - I am not that lucky but it was definitely 07:28 when it got Vcc and the last time is reported as 07:18. This alone makes me think it might be more insidious than just the coin cell, but it is an easy change to try before anything else. It also exhibits the symptoms of a failed cell now - having been on Vbat all night (so the cell has had a kicking), if I drop power for just a few minutes and then reconnect I get the same thing... so it looks like the cell recovers with prolonged Vcc (no load on Vbat) but 5 minutes not enough.

Never seen anything like this before but then never had a failed cell before (really). Nothing in the datasheet says that the registers go static when the cell drops out in power-down - I really would have expected all zeroes. Can the relief of a few nA used by the oscillator really be enough to preserve the registers? The evidence suggests so.

On the upside, it does provide a mechanism for a "time untrustworthy" test and at what point that happened. Could be useful.

UPDATE: Definitely looking like a failed cell... parasitic Vcc from the console port was holding power on the circuit enough to keep the RTC alive (but nothing else). I reckon the diode clamp on the serial Rx must have been leaking power from the idle PC Tx pin held in a marking state. If I unplug the USB<->serial dongle and then remove Vcc , I can get it to complain every time. Need to get into the habit of carrying a DMM with me everywhere... maybe there is a use for these piddly little scopes for a tenner from China? would go in my travel bag no probs and could be better than nothing.
Edited by CaptainBoing 2019-07-04
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 01:32pm 03 Jul 2019
Copy link to clipboard 
Print this post

I used a DS3234 which was a spi RTC with extra sram, a sibling to the I2C version
used on the mites series. Excellent RTC, once I figured out the registers !!
IIRC (not sure) reading the clock registers after complete power loss (before new values) gave non-zero readings (noise) until they were written.
I know I called it a coin cell but it was smaller and thicker, even so they eventually expire. IIRC The IC datasheet mentioned backcurrent leaking through a diode to the cell, citing insurance approval for it as it was a low value, probably originally intended to just keep the cell up to scratch
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 03:34am 09 Jul 2019
Copy link to clipboard 
Print this post

Did a new button cell fix it ?
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 08:04am 09 Jul 2019
Copy link to clipboard 
Print this post

Morning isochronic.

TL;DR = no

It turned out to be a bit of a faff.

I checked the cell and it was reading about 1.4V so I did change it but having verified the cell voltage was stable on the bench (steady as a rock) and fitting it, the voltage on the RTC was 3.184 and then dropping... only by a millivolt every few seconds but a steady drop (=current draw well above the promised nA). Tested to VCC, nothing, tested for HRs and shorts, nothing. Had to be a dodgy chip so I binned the RTC and replaced it (99p, meh).

New RTC showed zero voltage drop on VBat so happy about that. Powered up, MM complains of no RTC so traced everything out thinking I maybe crossed SCL & SDA when I put the new unit in, but all good. Took the new RTC out and probed all the connector pins to chip, just running a probe up both sides of the chip to get a beep - nothing from the VCC connection (pin 2). Double-checked, nope. soldered a short jumper from the bottom of the connector pin to the chip's pin 2, plugged in and bingo.

These RTCs were cheap, off ebay I think and both had faults of a kind... one was probably a dodgy knock-off chip and the other had a fault on the PCB.

Ho-hum... those inscrutable Chinese scamps!

This is the first time I have had any problems with them then two in a row. Lesson learned, everything gets checked before I use them in future. I am (slowly) building up a workshop assistant MM and one of the test programs it will have is the full i2c scan and RTC test that way I can simply plug a module in a socket and it will give it the once over - having trouble finding a case so it is a bit of a mess atm.

cheers
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 12:50pm 09 Jul 2019
Copy link to clipboard 
Print this post

commiserations .. it recalls painful memories of sorting out a RTC i/o,
bit by painful bit . The sparkfun module was fine, but the ic uses very low power, and some short leads were picking up bit-flipping intermittent RF .
One block of flats, nearly thirty wifi local networks, lots of bluetooth - and I think my microwave oven leaks a bit too - ( I hope )
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025