Bird
0
0

Identify the error in this heartbeat task code snippet:

medium📝 Troubleshoot Q14 of 15
FreeRTOS - Design Patterns for RTOS
Identify the error in this heartbeat task code snippet:
void vHeartbeatTask(void *pvParameters) {
  while(1) {
    printf("Heartbeat\n");
    vTaskDelay(1000);
  }
}
AvTaskDelay() argument should be in ticks, not milliseconds
Bprintf() cannot be used inside tasks
Cwhile(1) should be for(;;)
DMissing task notification call
Step-by-Step Solution
Solution:
  1. Step 1: Check vTaskDelay argument type

    vTaskDelay() expects delay in ticks, not milliseconds directly.
  2. Step 2: Correct usage

    Use pdMS_TO_TICKS(1000) to convert 1000 ms to ticks for vTaskDelay.
  3. Final Answer:

    vTaskDelay() argument should be in ticks, not milliseconds -> Option A
  4. Quick Check:

    vTaskDelay(ms) wrong, use pdMS_TO_TICKS(ms) [OK]
Quick Trick: Always convert ms to ticks with pdMS_TO_TICKS() [OK]
Common Mistakes:
  • Passing milliseconds directly to vTaskDelay()
  • Thinking printf() is disallowed in tasks
  • Believing while(1) is invalid syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes