![]() |
Forum Index : Microcontroller and PC projects : RTC settime
Author | Message | ||||
VK2AHB Regular Member ![]() Joined: 28/07/2022 Location: AustraliaPosts: 51 |
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: AustraliaPosts: 2642 |
RTC SetTime sets the external RTC. RTC GetTime sets the MMBasic clock to the RTC time. |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
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: NetherlandsPosts: 5091 |
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: AustraliaPosts: 51 |
Thanks for that, RTC AUTO ENABLE did the trick. Paul |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |