UAT 204 Microcontrollers and Embedded Systems
Worksheet 5 Tasks on FreeRTOS
Objective
Build a multi-task RTOS system, assign rate-monotonic priorities, compare measured timing with calculation and test the watchdog
Equipment and materials
- Pico 2 with an SDK supporting FreeRTOS
- Logic analyzer
- LED and the sensor from worksheet 4
- Computer with Python and the module 5 example code
Safety
- Low-voltage bench work; no flying
Steps
- Create a FreeRTOS project with three tasks: sensor every 10 ms, frame every 100 ms, LED every 500 ms
- Assign rate-monotonic priorities
- Measure each task's real timing by toggling GPIO pins with a logic analyzer
- Add a simulated heavy load in a low-priority task; check the sensor task stays on time
- Enter measured values into Example 1 and compare calculation with measurement
- Enable the watchdog, simulate a hung task and observe the reset
Record of results
| Task | Priority set | Set period T (ms) | Measured period (ms) | Measured run time C (ms) | On time after the load? |
|---|---|---|---|---|---|
| Task set | Computed U | Bound n(2^(1/n) − 1) | Missed deadlines in simulation | Result measured on the board |
|---|---|---|---|---|
Questions
From Table 2, what is your task set's U, is it below the Liu and Layland bound, and do the board measurements agree with the calculation?
When the heavy load was added in a low-priority task, why did the sensor task stay on time? What would happen if the load had a higher priority than the sensor task?
If U exceeds the n(2^(1/n) − 1) bound but not 1, can you conclude the system will miss deadlines? Explain with the lesson's Example 1.
How does a watchdog help a drone in flight, and why must a hung task be unable to feed the watchdog?
Check before you hand in
What to hand in
- FreeRTOS project code
- Task timing captures before and after the load
- Calculation against measurement table
- Watchdog test record