pvTimerID vs TimerHandle_t

Hello, I was wondering if having both TimerHandle_t and pvTimerID , has any special functionality , other than simplifying the way to refer/recognise a Timer. Maybe it is obvious and i am blind, but it seems to me that both are unique identifiers for the same Timer, so one could do all the functionality with just one of them. Please enlighten my! Alex

pvTimerID vs TimerHandle_t

I’m not sure of the context in which you are asking your question. TimerHandle_t is the type of variables used to point to timer handles, whereas presumably the pvTimerID you are referring to is the ID that is assigned to the timer. If so, then the ID is assigned to the timer to allow the same callback function to be used by multiple timers. When you are inside the callback function you can query the timer’s ID to see which time actually expired. Look at the vTimerCallback() function in the example on the following page to see how this is done: http://www.freertos.org/FreeRTOS-timers-xTimerCreate.html Regards.

pvTimerID vs TimerHandle_t

I assume I understand what you tell me… or better that is what I already thought. But then wouldn’t it be equivalent to run through the array of saved TimerHandlet s’ and get my own ID from the array Index? In the example there is the following concept: TimerHandlet timers[5]; for(int i=0;i<5;i++) timers[i]=xTimerCreate(..); wouldn’t this allow me to recover the actual timer by running the array and comparing the handle? Thank You Alex

pvTimerID vs TimerHandle_t

Yes – that would be equally as valid. Regards.

pvTimerID vs TimerHandle_t

The difference is that YOU get to control the pvTimerID value, so it can point directly to data you want/need the timer to use. The TimerHandle_t on the other hand is an opaque pointer to the Timer Control block, so to use that to identify the timer requires doing a time wasting search through a list of timers, but is just what FreeRTOS needs to process the timer.