Complete the code to create a FreeRTOS timer named "myTimer".
TimerHandle_t myTimer = xTimerCreate("myTimer", pdMS_TO_TICKS(1000), pdFALSE, (void *)0, [1]);
The last parameter of xTimerCreate is the callback function that runs when the timer expires. Here, it should be vTimerCallback.
Complete the code to start the timer "myTimer" immediately.
if (xTimerStart(myTimer, [1]) != pdPASS) { // Handle error }
The second parameter of xTimerStart is the block time to wait for the command to be sent to the timer command queue. Using 0 means do not wait.
Fix the error in stopping the timer "myTimer" with a block time of 10 ms.
if (xTimerStop(myTimer, [1]) != pdPASS) { // Handle error }
The block time parameter expects ticks. Using pdMS_TO_TICKS(10) converts 10 milliseconds to ticks correctly.
Fill both blanks to create and start an auto-reload timer named "autoTimer" with a 500 ms period.
TimerHandle_t autoTimer = xTimerCreate("autoTimer", [1], [2], NULL, vAutoTimerCallback); xTimerStart(autoTimer, 0);
The second parameter is the timer period in ticks, so pdMS_TO_TICKS(500) converts 500 ms to ticks. The third parameter is pdTRUE to make the timer auto-reload.
Fill all three blanks to create a one-shot timer named "oneShot" with a 2000 ms period, start it, and check for success.
TimerHandle_t oneShot = xTimerCreate("oneShot", [1], [2], NULL, vOneShotCallback); if (xTimerStart(oneShot, [3]) != pdPASS) { // Handle error }
The timer period is 2000 ms converted to ticks with pdMS_TO_TICKS(2000). The timer is one-shot, so pdFALSE is used for auto-reload. The start block time is zero to start immediately.
