Access to the Real-Time Clock

The syntax of the "T" command is:
T[ ]=[ ]Sec#[[[[[[ [ ]Min#] [ ]Hr#] [ ]WDay#] [ ]Date#] [ ]Mo#] [ ]Yr#]
  where [ ] means zero or more spaces,
  "Sec#"  is a numeric value, 0 to 59, to set the Seconds value
  "Min#"  is a numeric value, 0 to 59, to set the Minutes value
  "Hr#"   is a numeric value, 0 to 23, to set the Hour value
  "WDay#" is a numeric value, 1 (Monday) to 7 (Sunday), to set the Weekday
  "Date#" is a numeric value, 0 to 31, to set the Date value
  "Mo#"   is a numeric value, 1 to 12, to set the Month value
  "Yr#"   is a numeric value, 0 to 255, to set the modulo 2000 Year value
Notes:
  No distinction is made between uppercase and lowercase.
  Numeric values may be specified in either decimal or hexadecimal format.

The Operating System maintains a Real-Time Clock, sometimes called a "Wall Clock", which is a 7-byte structure beginning at the SRAM address sWallClock, which also includes the date and day of the week. The values may be viewed using the system command "DS 0x1D8 7" or changed using the system command "ES 472 = Sec# Min# ...", for example. The purpose of the "T" command is to assist with setting the clock values without having to remember where they live. It also makes it easy to sync one or more clocks remotely when using the nRF radios.

Although all the brackets of extended Backus-Naur Form (BNF) syntax appear to be intimidating for a command like this, it really is a simple command. In its most terse form, "T=0", or only slight longer, "T = 5", as examples, only the seconds value is changed. This is handy when trying to synchronize the clock to the second when all of the other values are already correct.

To set the minutes, the seconds must also be set first, so the next more complex form of the command would be "T=0 10", for example, which would set 0 seconds and 10 minutes. There must be at least one space between the seconds and minutes values, though there may be more.

To set the hour, both the seconds then the minutes must first be set, so that format would be "T=0 0 14" to set the clock to 2:00:00 PM, for example. To set the weekday, then the first parameter is the seconds, then the minutes, then the hour, and finally the weekday value, with at least one space between each value. And so on ... Of course, "ES 0x1DC = 7 6 16" could be used to directly set the date and month and year, if only those portions need to be changed, for example.

m>@ 0x7000
Copyright, 2013-2021, SCADA Support Group, Inc.
Sonoma, CA 95476  ###.###.####
MIRTOS for SSG Dual Relay Controller
Version 3.01 - Monday, March 28, 2022
Serial Number: #########
Cause of the last reset: (no MCUSR bit was set)
>DS+ 0x1D8 7    ; Check the present clock values after a reboot
SRAM contents:
01D0:                         -04 00 09 02 1F 07 12             .......
>T = 0 0 13   ; Synchronize the clock to 1:00:00 PM
>DS+ 472 7    ; Display the present value using the hex SRAM address
SRAM contents:
01D0:                         -01 00 0D 02 1F 07 12             .......
>T = 15 0 13 1 4 9 18  ; Complete time & date: 1:00:15 on Mon., Sept 4, 2018
>DS+ 472 7    ;
SRAM contents:
01D0:                         -10 00 0D 01 04 09 12             .......
>                                                                               
Details:
      The update process does not validate each element every second. When the seconds exceed 59, they are set to 0 and the minutes are incremented. When the minutes exceed 59, they are set to 0 and the hours are incremented. When the hours exceed 23, they are set to 0 and the weekday and date are incremented. Well, you get the idea.
When the system reboots, it initializes the time and date to 9:00 AM on the day that Operating System was released, which for version 3.01, is Monday, March 28, 2022.
The system handles leap-year correctly, until 2100, which is not a leap year.
To get the complete 4-digit year, add 2000 to the value stored in the system variable bRTC_Year.
 
See also:
The Registers System Command, the DumpRegs_Begin System Function, and the PrintDateAndTime.Asm example code.