Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:54 02 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 : RTC settime

Author Message
VK2AHB
Regular Member

Joined: 28/07/2022
Location: Australia
Posts: 51
Posted: 08:15am 08 Sep 2022
Copy link to clipboard 
Print this post

Does this set the 2040 chip clock, the external 3231 or both? I can't get mine to keep the time if I disconnect the power. Time resets to 00:00:00.

Paul VK2AHB
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2642
Posted: 08:47am 08 Sep 2022
Copy link to clipboard 
Print this post

RTC SetTime sets the external RTC.
RTC GetTime sets the MMBasic clock to the RTC time.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 10:15am 08 Sep 2022
Copy link to clipboard 
Print this post

The MMBasic clock will always reset to 00:00:00 as it has no battery. The RTC has battery backup so it keeps running. :)

If you have a RTC connected, you can use OPTION RTC AUTO ENABLE to automatically set the MMBasic clock from the RTC on boot and every hour. You can turn this off with OPTION RTC AUTO DISABLE.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5091
Posted: 10:29am 08 Sep 2022
Copy link to clipboard 
Print this post

note that for the OPTION RTC AUTO ENABLE to work you do need to define the I2C bus where the DS3231 connects. This is also set with an OPTION statement.

So for RTC SETTIME and RTC GETTIME to work you need to set following OPTIONS:

OPTION SYSTEM I2C sda_pin,scl_pin  (i.e. OPTION SYSTEM I2C GP14,GP15)
OPTION RTC AUTO ENABLE

Then reboot the system

Then set the RTC to the correct time

RTC SETTIME 2022,09,08,12,23,10

You can reboot the system, or do a RTC GETTIME

And you will have the correct time available in variables
TIME$
DATE$

Regards,

Volhout

P.S. this is also explained on page 32 of the user manual
Edited 2022-09-08 20:31 by Volhout
PicomiteVGA PETSCII ROBOTS
 
VK2AHB
Regular Member

Joined: 28/07/2022
Location: Australia
Posts: 51
Posted: 12:35pm 08 Sep 2022
Copy link to clipboard 
Print this post

Thanks for that, RTC AUTO ENABLE did the trick.

Paul
 
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