FreeRTOS with Arduino in Proteus Simulation - Expanded Exercises
Setup Exercise:
Create 4 tasks with 4 different priorities, describe the effect of different priority and explain
those different
Exercise 1: Basic Task Creation
Create four FreeRTOS tasks to blink four LEDs at different rates.
- LED1 (Pin 13) blinks every 200ms.
- LED2 (Pin 12) blinks every 500ms.
- LED3 (Pin 11) blinks every 1000ms.
- LED4 (Pin 10) blinks every 1500ms.
Questions:
- How does FreeRTOS manage task switching between multiple tasks?
- What happens if two tasks have the same priority?
Exercise 2: Task Synchronization with Semaphore
Use a binary semaphore to synchronize four LED tasks.
- LED1 blinks every 500ms.
- LED2 blinks only when the semaphore is available.
- LED3 blinks after LED1 with a delay of 300ms.
- LED4 blinks after LED2 with a delay of 300ms.
Questions:
- What happens if the semaphore is not given back?
- How can you prioritize access to the semaphore among tasks?
Exercise 3: Task Communication using Queue
Implement four tasks to communicate using a queue:
- Producer1 sends incremental numbers every 1 second.
- Producer2 sends even numbers every 1.5 seconds.
- Consumer1 receives and prints numbers every 500ms.
- Consumer2 receives and prints numbers every 800ms.
Questions:
- What happens if the queue is full?
- How can you prioritize messages from Producer1 over Producer2?
Exercise 4: Priority-based Task Scheduling
Create five tasks with different priorities:
- Low Priority Task1 prints 'Low Task 1' every 1 second.
- Low Priority Task2 prints 'Low Task 2' every 1 second.
- Medium Priority Task prints 'Medium Task' every 700ms.
- High Priority Task1 prints 'High Task 1' every 500ms.
- High Priority Task2 prints 'High Task 2' every 300ms.
Questions:
- How does FreeRTOS handle preemption between different priority tasks?
- What is the effect of setting equal priorities to two tasks?