AW: [En-Nut-Discussion] Synching Calldirect using NutOS

Harald Kipp harald.kipp at egnite.de
Mon Oct 13 17:12:29 CEST 2003


Hi Oliver,

I'd like to have a look, if you can send it to my email
address.

However, I'd avoid doing any updates within the interrupt
routine except incrementing a simple counter.

This is done in the newest update. NutGetSeconds() returns
the number of seconds since system start. In order to be
usable for timeout counting, the value of this counter
should continuously increment and never be set to any
other value like seconds of epoch etc. That would confuse
timeout calculations.

For RTC, you get the actual time, let's say, every hour
and use the system seconds counter as an offset:

u_long epo_secs = GetTimeFromSntp_or_whatever();
u_long epo_offs = NutGetSeconds();

The current time is then calculated by:

u_long current_time = epo_secs + (NutGetSeconds() - epo_offs);

epo_secs as well as current_time contain the number of
seconds since 1st of January 1970. Date, weekdays and all
that stuff will be calculated from current_time.

For clock display applications a system wide event queue
triggering each full second might be helpfull too. But
a simple NutSleep(500) might be sufficient.

Another idea is to wake up the system on a specified time.
Fortunately the clock crystal timer keeps running in one
of the ATmega low power modes. This may be used to wake
up the system every 62.5 milliseconds. This would make
sense only, if we shutdown the Ethernut Controller as well.
At least the SMSC supports some kind of wake-on-lan.

Lots of ideas, comments are welcome.

Regards,

Harald

At 16:16 13.10.2003 +0200, you wrote:
>Hi All,
>
>Last weekend I wrote some code to get something similar like a RTC...
>It's based on the standard (or just MS?) C struct '_tm' and uses the
>timer0 interrupt to update the "current" time and date on a per second
>base.
>Included leap year and day of week calculation.
>
>If Harald is interested, perhaps it can be added to the Nut/OS. Please
>let me know!
>
>Oliver.




More information about the En-Nut-Discussion mailing list