[Oberon] FPGA - System Clock advance

Jörg joerg.straube at iaeth.ch
Thu Feb 28 21:54:14 CET 2019


Tomas

Your approach is not so bad. Needs some refinements though...
- Kernel.Time() counts the ms since last reboot. No immediate correlation to time and date. Kernel.Time is positive for ~25 days, and then the value is negative for the next ~25 days and so on.
- Kernel.Clock() is meant to store date and time in seconds. Depending on the format used, it can store upto 136 years. The format used in PO2013 allows to store ~64 years.

You can (and must) use Kernel.Time() to check how many ms passed since the last call to your routine. It's basically used for timers.
Do use Kernel.Time() to calculate the difference between calls.

Kernel.Clock() has a totally different format. It is either updated by a HW clock or by a SW clock (that works with Kernel.Time()).

br
Jörg


Am 28.02.19, 20:26 schrieb "Oberon im Auftrag von Tomas Kral" <oberon-bounces at lists.inf.ethz.ch im Auftrag von thomas.kral at email.cz>:

    Hi,
    
    Getting ready for time ticks, while toying with this code.
    
      PROCEDURE Time*;
        VAR s, dt, hr, min, sec: INTEGER;
      BEGIN
        s := Kernel.Time() (*milis*) DIV 1000; (*seconds*) Texts.WriteInt(W, s, 6);
        hr := s DIV 3600; min := (*s - hr*3600*) s MOD 3600 DIV 60; sec :=  s MOD 60;
        Texts.WriteInt(W, hr, 6); Texts.WriteInt(W, min, 6); Texts.WriteInt(W, sec, 6);
        s := hr*3600 + min*60 + sec; Texts.WriteInt(W, s, 6); (*sanity check*)
        dt := hr*1000H + min*40H + sec; (*system date time*)
        (* Kernel.SetClock(dt); *) Texts.WriteClock(W, dt);
        Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
      END Time;
    
    Now, in `Oberon.Mod' we have `GC' task getting awaken every 1000 ms = 1 sec. That could be used to advance system date time as well, using some of the code above.
    
    The above code itself however consumes some time delta, not sure if need be compensated for?
    
    Also, we could introduce a new message type for time updates, and broadcast by `Viewers.Broadcast()', so any code can poll the Kernel.Clock() by a given period?
    
    -- 
    Tomas Kral <thomas.kral at email.cz>
    --
    Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
    https://lists.inf.ethz.ch/mailman/listinfo/oberon
    




More information about the Oberon mailing list