ECE 367 FreeRTOS Lab 3
ECE 367 FreeRTOS Lab 3
Operating Systems
(ECE 367)
Dr. Rajiv Ranjan Singh
Professor
Department of Electronics and Communication
(ECE) Engineering
Lab – 03
FreeRTOS on Windows Simulator using
Eclipse and MingW
Tasks in FreeRTOS
2
Outline (Lab - 03)
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 3
Creating a Task: Example 1
/*Below we have a simple Hello World Task Prototype */
void HelloTask(){
A Hello World Task
while(1)
Prototype – in Eclipse &
printf("Hello World\n"); MinGW
vTaskDelay(1000); /*1000 ms = 1 sec delay*/
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 4
Creating a Task: Example 1(a)
/*Below we have a simple Hello World Task Prototype with Task Delete facility */
void HelloTask(){
A Hello World Task
int count1=0;
Prototype – in Eclipse &
while(1){ MinGW
printf("Hello World : %d\r\n", count1++);
if(count1 == 10){
vTaskDelete(HT1); // Declare Global Handler HT1 on top
}
}
} /*Above we have a simple Hello World Task Prototype with Task Delete facility */
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 5
Creating a Task: Example 1
/*Insert ERTOS (ECE 367) Codes for Practice below this for Simulation Lab*/
/*Insert ERTOS (ECE 367) Codes for Practice above this for Simulation Lab*/
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 6
Creating a Task: Example 2
/*Below we have a Task 1 Prototype which will be created in Task 2 */
void HelloTask1(){
Task 1 Prototype which
int count1=0; will be created in Task 2 –
in Eclipse & MinGW
while(1){
printf("Hello World1 : %d\r\n", count1++);
//if(count1 == 10){
// vTaskDelete(HT1);
}
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 7
Creating a Task: Example 2
/*Below we have a Task 2 Prototype which creates Task 1 */
void HelloTask2(){
int count2=0;
while(1){
printf("Hello World2 : %d\r\n", count2++);
vTaskDelay(4000); /*4000 ms = 4 sec delay*/
if(count2 == 10){
vTaskDelete(HT2); Task 2 Prototype which
}
creates Task 1 – in Eclipse
} & MinGW
}
/*Above we have a Task 2 Prototype which creates Task 1 */
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 8
Creating a Task: Example 2
int main( void )
{
/* This demo uses heap_5.c, so start by defining some heap regions. heap_5 is only
used for test and example reasons. Heap_4 is more appropriate. See
http://www.freertos.org/a00111.html for an explanation. */
prvInitialiseHeap();
/* ---------------------------------------- */
//xTaskHandle HT1;
//xTaskCreate(HelloTask1, "HelloTask1", configMINIMAL_STACK_SIZE, NULL, 1, &HT1);
/* ----------------------------------------- */
Part of main() function for creating task
handlers or creating both Task 1 and Task 2
using xTaskCreate() function.
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 9
Creating a Task: Example 2
/* ---------------------------------------- */
// xTaskHandle HT2;
xTaskCreate(HelloTask2, "HelloTask2", configMINIMAL_STACK_SIZE, NULL, 2, &HT2);
/* ----------------------------------------- */
/* ---------------------------------------- */
/*xTaskHandle NT1;
xTaskCreate(vTask1, "vTask1", configMINIMAL_STACK_SIZE, NULL, 1, &NT1);*/
/* ----------------------------------------- */
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 10
Next Lab
Queues and Mailboxes on Windows Simulator using Eclipse and
MingW
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 11
Bibliography
K.C. Wang, “Embedded and Real-Time Operating Systems,” Springer
International Publishing, 2017.
Rajib Mall, “Real Times Systems: Theory and Practice,” Pearson Education.
Jonathan W. Valvano, “Embedded Systems: Real-Time Operating Systems for
Arm® Cortex™-M Microcontrollers,” CreateSpace Independent Publishing
Platform.
Wolf, Wayne, Computers as Components – Principles of Embedded Computing
System Design, Second Edition, Morgan-Kaufmann, 2008.
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh 12
.
Thank You!
©These lecture slides have been prepared for the benefits of the registered students of the course
Embedded Real Time Operating Systems (ECE 367) of Presidency University, Bengaluru. Anybody
who may wish to use these slides for educational purpose could use it without any explicit permission. Any
kind of redistribution, alteration, and commercial use of this material is strictly prohibited.
29 April 2021 Embedded Real Time Operating Systems (ECE 367) @Dr. Rajiv Ranjan Singh