[En-Nut-Discussion] Re-triggerable timer in Nut/OS

Ulrich Prinz ulrich.prinz at googlemail.com
Thu Nov 15 11:39:42 CET 2012


is someone aware of a re-triggerable timer function in Nut/OS?
I know NutTimerStart() and NutTimerStop().

Use case 1:
I'd like to collect some data that is to be written into an EEPROM.
I'd like to prevent the EEPROM from being worn out by multiple
successive writes to the same bank. So I'd prefer to collect all data
first and then write it at once if no further data was set for a
specific amount of time.

Use case 2:
In a serial protocol I have fixed telegrams that transport multiple
values. If a value changes the telegram has to be sent for updating
the remote host. If now multiple values change, the telegram has to be
sent multiple times if the changes came while already assembling the

Possible Solution:
Put the eewrite() into a function that is called by NutTimerStart()
incorporating a timeout of some ms.
Everytime data is requested to be written into the eeprom, the Timer
needs to be restarted even it already runs.

NutTimerRestart() has the same parameters as NutTimerStart() but
checks if the HANDLE is already assigned and just resets the timeout
counter. If not it creates and starts the timer by calling

I know that one could write threads that regularly check for updates
or something like this. But it is difficult to re-trigger threads as
well as they have to run and check for a counter that is decrementing.
This is a lot of overhead to just execute a single function after a
variable amount of time.


More information about the En-Nut-Discussion mailing list