Actions

EmSys

Difference between revisions of "FreeRTOS Exercise Lab01"

From EdWiki

(Created page with "__NOTOC__ * Create a CCS Project using FreeRTOS Project Template * Add [{{SERVER}}/emsys/rtos/freertos/printf-stda...")
 
m (FreeRTOS Lab 01)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
== FreeRTOS Lab 01 ==
 +
# Create a CCS Project using FreeRTOS [[EmSys:Create a Project using FreeRTOS Project Template| Project Template]]
 +
# 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])
 +
# 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;
  
* Create a CCS Project using FreeRTOS [[EmSys:Create a Project using FreeRTOS Project Template| Project Template]]
+
<syntaxhighlight lang="c">
* Add [{{SERVER}}/emsys/rtos/freertos/printf-stdarg.c printf-stdarg.c] file to project ('''Project > Add Files ...''')
+
void vTaskn(void * pvParameters)
* 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])
+
{
 +
    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:next.gif|right|link=EmSys:LTC1661 SPI DAC]]
 +
[[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