Bird
0
0

Which of the following is the correct way to create a FreeRTOS software timer for heartbeat every 1000 ms?

easy📝 Syntax Q3 of 15
FreeRTOS - Design Patterns for RTOS
Which of the following is the correct way to create a FreeRTOS software timer for heartbeat every 1000 ms?
AxTimerCreate("HeartbeatTimer", 1000, pdFALSE, NULL, HeartbeatCallback);
BxTimerCreate("HeartbeatTimer", pdMS_TO_TICKS(1000), pdTRUE, NULL, HeartbeatCallback);
CxTimerCreate("HeartbeatTimer", 1000, pdTRUE, NULL, HeartbeatCallback);
DxTimerCreate("HeartbeatTimer", pdMS_TO_TICKS(1000), pdFALSE, NULL, HeartbeatCallback);
Step-by-Step Solution
Solution:
  1. Step 1: Understand timer parameters

    pdMS_TO_TICKS converts ms to ticks; pdTRUE means auto-reload (periodic).
  2. Step 2: Check correct syntax for periodic 1000 ms timer

    xTimerCreate("HeartbeatTimer", pdMS_TO_TICKS(1000), pdTRUE, NULL, HeartbeatCallback); uses pdMS_TO_TICKS(1000) and pdTRUE for periodic timer.
  3. Final Answer:

    xTimerCreate("HeartbeatTimer", pdMS_TO_TICKS(1000), pdTRUE, NULL, HeartbeatCallback); -> Option B
  4. Quick Check:

    Periodic timer needs pdMS_TO_TICKS + pdTRUE [OK]
Quick Trick: Use pdMS_TO_TICKS for ms to ticks conversion [OK]
Common Mistakes:
  • Forgetting pdMS_TO_TICKS conversion
  • Using pdFALSE for periodic timer
  • Passing wrong callback function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes