How to use Kernel Timers

The following questions are related to Kernel Timers part of libkelib.a (not to be confused with the peripheral timer):

  1. how many timers can be set or enabled at the same time?
  2. if more than one timer can be set, then, should all timers be bound to the same task?
1 Like


Hypothetically, this limit is enforced by how much memory you have available for you Heap. The Kernel Timers will use malloc to create a new memory block for you timers each time one is created. Each timer requires the following amount of memory on the Heap; 32bit time value, 32bit message ID, 32bit Task ID, and a 32bit Pointer.

The other limit will be hit depending on what System Clock and Timer step you are using. You should ensure that the kernel is able to check all of the active timer values before the next smallest Timer step is triggered.

This is not necessary for the timers to function. Assigning them all to the same task would simply allow you to create a handler function for all of the timers easily, thought this can be done on a Message ID basis instead of a Task ID basis as well.