0% found this document useful (0 votes)
6 views2 pages

FreeRTOS Task Delay Example

Project idea

Uploaded by

jonesab0717
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)
6 views2 pages

FreeRTOS Task Delay Example

Project idea

Uploaded by

jonesab0717
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

#include <stdio.

h>

#include "FreeRTOS.h"

#include "task.h"

// Task 1 function

void vTask1(void *pvParameters) {

while (1) {

printf("This is task 1\n");

fflush(stdout);

vTaskDelay(pdMS_TO_TICKS(100)); // 100 ms delay

// Task 2 function

void vTask2(void *pvParameters) {

while (1) {

printf("This is task 2\n");

fflush(stdout);

vTaskDelay(pdMS_TO_TICKS(500)); // 500 ms delay

int main(void) {

// Create Task 1

xTaskCreate(
vTask1, // Function that implements the task

"Task1", // Text name for the task

1000, // Stack size in words

NULL, // Parameter passed into the task

3, // Priority

NULL); // Task handle

// Create Task 2

xTaskCreate(

vTask2,

"Task2",

100,

NULL,

1,

NULL);

// Start the scheduler

vTaskStartScheduler();

// The program should never reach here

for (;;);

return 0;

You might also like