0
0
FreeRTOSprogramming~30 mins

Tick timer and scheduler in FreeRTOS - Mini Project: Build & Apply

Choose your learning style9 modes available
Tick Timer and Scheduler in FreeRTOS
📖 Scenario: You are working on a simple embedded system using FreeRTOS. Your task is to set up the tick timer and create a basic scheduler that switches between two tasks periodically.
🎯 Goal: Build a FreeRTOS program that initializes the tick timer, creates two tasks, and uses the scheduler to switch between them, printing messages to show task execution.
📋 What You'll Learn
Create two tasks named Task1 and Task2
Set up the FreeRTOS tick timer with a tick rate of 1000 Hz
Use the FreeRTOS scheduler to switch between the tasks
Each task should print a message indicating it is running
Run the scheduler to start task switching
💡 Why This Matters
🌍 Real World
Embedded systems often use FreeRTOS to manage multiple tasks like sensor reading, communication, and control loops efficiently.
💼 Career
Understanding FreeRTOS tick timer and scheduler is essential for embedded software developers working on real-time applications.
Progress0 / 4 steps
1
Create two FreeRTOS tasks
Write code to create two tasks named Task1 and Task2 using xTaskCreate. Each task should run a function that prints a unique message in an infinite loop with a delay.
FreeRTOS
Need a hint?

Use xTaskCreate to create each task with the function name, a name string, stack size, parameters as NULL, priority 1, and no task handle.

2
Configure the FreeRTOS tick timer rate
Add a macro definition to set the FreeRTOS tick rate to 1000 Hz by defining configTICK_RATE_HZ as 1000 before including FreeRTOS headers.
FreeRTOS
Need a hint?

Define configTICK_RATE_HZ before including FreeRTOS headers to set the tick timer frequency.

3
Start the FreeRTOS scheduler
Add a call to vTaskStartScheduler() in main() after creating the tasks to start the FreeRTOS scheduler and begin task switching.
FreeRTOS
Need a hint?

Call vTaskStartScheduler() after creating tasks to start the FreeRTOS scheduler.

4
Run and observe task switching output
Run the program and observe the output. It should print alternating messages from Task 1 is running and Task 2 is running every second.
FreeRTOS
Need a hint?

Run the program on a FreeRTOS-supported environment or simulator to see the alternating task messages every second.