FreeRTOS Exercise Lab01

From EdWiki

FreeRTOS Lab 01

  1. Create a CCS Project using FreeRTOS Project Template
  2. Add printf-stdarg.c file to project (Project > Add Files ...)
  3. Initialize UART0 for 115,200 baud rate (assuming 16 MHz bus clock), 8 bit word length, no parity bits, one stop bit, FIFOs enabled. (UART0 Echo Source Code is available here)
  4. Create two tasks (vTask1 and vTask2) with equal priorities. vTask1 should display the string "Task 1 is Running ..." and vTask2 should display the string "Task 2 is Running ...".
  5. After Displaying the string, introduce a small (crude) Delay;
void vTaskn(void * pvParameters)
    for (;;) { 
        printf("%s", "Task n is Running ..."); 
        for( auto int32_t ul = 0; ul < 3180; ul++ ) { ; }
  • Observe which Tasks strings Displayed and Why?
  • Change Tasks priorities and Observe
  • Delay generated using a null loop
    the task effectively polled an incrementing loop counter until it reached a fixed value.
  • Disadvantages to any form of polling
    While executing the null loop, the task remains in the Ready state, ‘starving’ the other task of any processing time.
    During polling, the task does not really have any work to do, but it still uses maximum processing time and so wastes processor cycles.
  • Replace the polling null loop with a call to vTaskDelay() API function corrects this behavior.
    Set INCLUDE_vTaskDelay to 1 in FreeRTOSConfig.h