Actions

EmSys

Difference between revisions of "FreeRTOS Exercise Lab01"

From EdWiki

m (FreeRTOS Lab 01)
m (FreeRTOS Lab 01)
 
(5 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
# Add [{{SERVER}}/emsys/rtos/freertos/printf-stdarg.c printf-stdarg.c] file to project ('''Project > Add Files ...''')
 
# Add [{{SERVER}}/emsys/rtos/freertos/printf-stdarg.c printf-stdarg.c] file to project ('''Project > Add Files ...''')
 
# Initialize [[EmSys:TM4C123G Launchpad UART Programming | 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 [{{SERVER}}/emsys/tivac/tm4c_uart_echo.c here])
 
# Initialize [[EmSys:TM4C123G Launchpad UART Programming | 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 [{{SERVER}}/emsys/tivac/tm4c_uart_echo.c here])
# Create two tasks with equal priorities. Task1 and Task2 Tasks will display the string "Task 1 is Running ..." or "Task 2 is Running ..." accordingly
+
# 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 ...".
 
# After Displaying the string, introduce a small (crude) Delay;
 
# After Displaying the string, introduce a small (crude) Delay;
for( auto uint32_t ul = 0; ul < 3180; ul++ );
 
# Observe which Tasks strings Displayed and Why?
 
# Change Tasks priorities and Observe
 
# Replace the above crude delay with ''vTaskDelay'' function and Observe.
 
  
 +
<syntaxhighlight lang="c">
 +
void vTaskn(void * pvParameters)
 +
{
 +
    for (;;) {
 +
        printf("%s", "Task n is Running ...");
 +
        for( auto int32_t ul = 0; ul < 3180; ul++ ) { ; }
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 +
* 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
  
 +
<!--
 
[[File:prev.gif|left|link=EmSys:Getting Started with FreeRTOS]]  
 
[[File:prev.gif|left|link=EmSys:Getting Started with FreeRTOS]]  
<!-- [[File:next.gif|right|link=EmSys:LTC1661 SPI DAC]] -->
+
[[File:next.gif|right|link=EmSys:LTC1661 SPI DAC]]
 
[[File:home.gif|center|link={{SERVER}}/edwiki/Main_Page]]
 
[[File:home.gif|center|link={{SERVER}}/edwiki/Main_Page]]
 +
-->

Latest revision as of 09:41, 3 March 2020

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