Clarification on timer with a period of zero

Good day. There is a contradiction between the interface to xTimerCreate in timers.h (line140) and the book, and the code.

In timers.h it says that if you give xTimerCreate a xTimerPeriodInTicks value of zero then xTimerCreate (et al) will return a NULL.

The book says that if there isn’t enough memory it will return NULL, but doesn’t mention the zero period.

The implementation of xTimerCreate in timers.c doesn’t check to see if the period is zero and will only return a NULL if malloc failed.

Am I missing a detail in the code/book or is the code missing a detail?

Andrei from The Great White North.

Thanks for pointing this out - I think it may be the implementation changed but the documentation didn’t. 0 is indeed an invalid interval value (as it would cause the time to execute continuously), but the check against 0 is performed by an assert().

Ah, so if my customer turned off asserts, they would get something that looks like a valid timer and not blow up.

Okay, thanks, I’ll pass that along.


Web docs have been updated - so you will see the change after the next deployment. I suspect this inconsistency was introduced at the time the xTimerCreateStatic() function was implemented, at which time the common code between xTimerCreate() and xTimerCreateStatic() was moved to a separate function.