0% found this document useful (0 votes)
5 views3 pages

New Microsoft Word Document

The document contains a C program using FreeRTOS to create two tasks, Task-1 and Task-2, with error handling for task creation. It includes a main function that initializes the tasks and starts the scheduler, while each task has its own handler function that runs indefinitely. The program is structured to handle task creation failures and includes optional task handles for future management.

Uploaded by

Ahmed Zakaria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

New Microsoft Word Document

The document contains a C program using FreeRTOS to create two tasks, Task-1 and Task-2, with error handling for task creation. It includes a main function that initializes the tasks and starts the scheduler, while each task has its own handler function that runs indefinitely. The program is structured to handle task creation failures and includes optional task handles for future management.

Uploaded by

Ahmed Zakaria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#include "FreeRTOS.

h"

#include "task.h"

int main(void)

BaseType_t status;

// Create Task-1

status = xTaskCreate(task1_handler, "Task-1", 200, "Hello world from Task-1", 2,


&task1_handle);

// Error handling

if (status != pdPASS)

//your code here to print "Task-1 creation failed! "

while(1);

// Create Task-2

status = xTaskCreate(task1_handler, "Task-1", 200, "Hello world from Task-1", 2,


&task1_handle);

if (status != pdPASS)

//your code here to print "Task-2 creation failed! "

while(1);

}
// Start the scheduler

vTaskStartScheduler();

// Should never reach here

while(1);

// Task Handles (optional, but good for managing tasks later)

TaskHandle_t task1_handle = NULL;

TaskHandle_t task2_handle = NULL;

// Task-1 function

static void task1_handler(void *parameters)

while(1)

// your code here to print "Hello world from Task-1 "

// Task-2 function

static void task2_handler(void *parameters)

while(1)

// your code here to print "Hello world from Task-2 "


}

You might also like