[Oberon] FPGA - System Clock advance
Tomas Kral
thomas.kral at email.cz
Fri Mar 1 20:05:19 CET 2019
On Fri, 1 Mar 2019 11:45:59 +0100
Jörg Straube <joerg.straube at iaeth.ch> wrote:
> And look into Texts.WriteClock to learn how clock and date is
> supposed to be encoded in the 32 bits. You will have to adapt your DT
> to that as well.
I do this, advances time only, advancing date requires more
effort, leap year, months of 31,28,31,.. days.
Currently resolved by TIM broadcast on hourly basis.
Keeping cumulative time delta `dT' in milliseconds is a challenge
though, then `dT DIV 1000' would yield the deviation to add?
PROCEDURE DT; (*advance date time*)
VAR dt, ymd, hr, min, sec: INTEGER;
BEGIN
dt := Kernel.Clock();
ymd := dt DIV 20000H; (*year, month, day*)
hr := dt DIV 1000H MOD 20H; (*hour*)
min := dt DIV 40H MOD 40H; (*min*)
sec := dt MOD 40H; (*sec*)
INC(sec); (*advance time*)
IF sec > 59 THEN INC(min); sec := 0 END ;
IF min > 59 THEN INC(hr); min := 0 END ;
IF hr > 23 THEN hr := 0 END ;
(*TIM to advance date `ymd'*)
dt := ymd*20000H + hr*1000H + min*40H + sec;
Kernel.SetClock(dt);
END DT;
--
Tomas Kral <thomas.kral at email.cz>
More information about the Oberon
mailing list