0
0
FreeRTOSprogramming~30 mins

xTaskNotify() with value in FreeRTOS - Mini Project: Build & Apply

Choose your learning style9 modes available
Using xTaskNotify() with Value in FreeRTOS
📖 Scenario: You are working on a FreeRTOS-based embedded system where two tasks need to communicate. One task will send a notification with a value to another task to trigger an action.
🎯 Goal: Build a simple FreeRTOS program where TaskSender sends a notification with a value to TaskReceiver using xTaskNotify(). The receiver task will print the received value.
📋 What You'll Learn
Create two tasks: TaskSender and TaskReceiver
Use xTaskNotify() to send a value from TaskSender to TaskReceiver
Use xTaskNotifyWait() in TaskReceiver to receive the notification and value
Print the received notification value in TaskReceiver
💡 Why This Matters
🌍 Real World
Task notifications with values are used in embedded systems to signal events or pass small data between tasks efficiently.
💼 Career
Understanding task notifications is essential for embedded software developers working with FreeRTOS to build responsive and efficient multitasking applications.
Progress0 / 4 steps
1
Create Task Handles
Declare two task handles called TaskSenderHandle and TaskReceiverHandle initialized to NULL.
FreeRTOS
Need a hint?

Task handles are pointers used to identify tasks in FreeRTOS. Initialize them to NULL.

2
Create TaskReceiver Task Function
Write a task function called TaskReceiver that waits for a notification using xTaskNotifyWait() and stores the received value in a variable called receivedValue.
FreeRTOS
Need a hint?

Use xTaskNotifyWait() with clear bits 0x00, clear all bits on exit 0xffffffff, and wait forever portMAX_DELAY.

3
Create TaskSender Task Function and Send Notification
Write a task function called TaskSender that sends a notification with the value 123 to TaskReceiverHandle using xTaskNotify() with the action eSetValueWithOverwrite.
FreeRTOS
Need a hint?

Use vTaskDelay() to wait 1000 milliseconds between notifications.

4
Print Received Value in TaskReceiver
Add a printf statement inside TaskReceiver after xTaskNotifyWait() to print the received value in the format: "Received notification value: %lu\n".
FreeRTOS
Need a hint?

Use printf to show the value received from the notification.