Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:09 01 Aug 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 : How to lockup the DS3231 RTC on the MM+

Author Message
MMAndy
Regular Member

Joined: 16/07/2015
Location: United States
Posts: 91
Posted: 03:38am 26 Sep 2015
Copy link to clipboard 
Print this post

How to lockup the DS3231 RTC on the MM+
Beta 4.7B30

Try this code snippet ...

Do
RTC Gettime
? Time
? Date
Pause 1 '<----<<<
Loop

Obviously, you need to change the pause from 1 ms to 10 ms
for reliable operation. This allows enough time for reading the
I2C time/date bytes.

In some cases, it jams the RTC/MM+ so bad that you need to
cycle power on and off to clear it from this halting error?

BTW ... There should be no reason why you should poll less
than 1 second (1000ms) since the RTC only updates once a second but
by a programming error it will cause your program to halt.

Edited by MMAndy 2015-09-27
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 03:31pm 26 Sep 2015
Copy link to clipboard 
Print this post

An interesting find.

You are quite correct though, in that in normal code, you would never repeatedly poll the RTC like this in a loop. Therefore, assuming a programmer did do this, and cause this to happen, then it is clearly a case of 'Human error' over a firmware bug per-se' in my humble opinion. It is reasonably well known by those who use I2C at all, that incorrect use of the bus can lead to lock-ups and other odd behaviour, so I guess the onus is on the user to make sure they don't confuse Mr. I2C.
Smoke makes things work. When the smoke gets out, it stops!
 
MMAndy
Regular Member

Joined: 16/07/2015
Location: United States
Posts: 91
Posted: 12:24pm 27 Sep 2015
Copy link to clipboard 
Print this post

FYIO ... for the speed freaks
Further testing reveals that a RTC poll rate of 2 ms. could be acceptable. Using 10 ms. was way too much. @ 100Khz / 8 bits per byte = 12,500 bytes per second. For 1 ms. 12.5 bytes. Since the time/date uses ~ 12 bytes + I2C overhead then 2 ms. delay between polls might/could be acceptable. Anything less than 2 ms. (0 or 1 ms.) will lock it up.
Edited by MMAndy 2015-09-28
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 724
Posted: 08:10pm 28 Sep 2015
Copy link to clipboard 
Print this post

I don't see any Situation/need of reading the RTC in intervalls of ms.
This thread is for > /dev/null
😄Edited by atmega8 2015-09-30
 
MMAndy
Regular Member

Joined: 16/07/2015
Location: United States
Posts: 91
Posted: 06:27am 29 Sep 2015
Copy link to clipboard 
Print this post

We found this problem by accident. In our MicroMite controller, we had to make sure that at any given RTC time/date setpoint our control digital output would be always executed and not skipped due to delays in other subs/functions. A very fast RTC poll rate in ms. was required. Putting a 2 ms. pause after the RTC Gettime command provided for 100% reliability with no RTC halting.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 01:29pm 29 Sep 2015
Copy link to clipboard 
Print this post

Over the medium term the internal Micromite clock would keep perfect time and not be upset by sub/fun or any other BASIC commands. You only need to poll the RTC every few hours

For me this is a very law priority issue and the fault will probably turn out to be caused by the RTC,

Geoff
Geoff Graham - http://geoffg.net
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 02:25pm 29 Sep 2015
Copy link to clipboard 
Print this post

On the MM+, I set the internal RTC with no external RTC module at all, and left it running and after three days(36 hrs), the internal RTC was off by about one second, with reference to an online clock, which I used to set the RTC in the MM+.

This is really excellent, but I suppose that is to be expected with a crystal oscillator reference for the MM+ though. So, in a nutshell, in one of my boards using the MM+, I have allowed for an external RTC module, but don't plan to actually use it, as the system clock is so accurate on the MM+. Not the case with the RC-based RTC in the standard MM, which do drift a bit more.
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 04:14pm 29 Sep 2015
Copy link to clipboard 
Print this post

  Grogster said   and after three days(36 hrs),

I didn't realise that you had such short (12hr) days in NZ.

Jim
VK7JH
MMedit
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 04:29pm 29 Sep 2015
Copy link to clipboard 
Print this post

Whoops!!!!!

Typo - sorry.

Make that 72 hrs.........
Smoke makes things work. When the smoke gets out, it stops!
 
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