UAT 204 Microcontrollers and Embedded Systems

Worksheet 5 Tasks on FreeRTOS

Lab 6 hAssesses CLO2, CLO1

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

  1. Create a FreeRTOS project with three tasks: sensor every 10 ms, frame every 100 ms, LED every 500 ms
  2. Assign rate-monotonic priorities
  3. Measure each task's real timing by toggling GPIO pins with a logic analyzer
  4. Add a simulated heavy load in a low-priority task; check the sensor task stays on time
  5. Enter measured values into Example 1 and compare calculation with measurement
  6. Enable the watchdog, simulate a hung task and observe the reset

Record of results

Table 1 Measured timing of each task from the logic analyzer
TaskPriority setSet period T (ms)Measured period (ms)Measured run time C (ms)On time after the load?
Table 2 Example 1 calculation against measurement
Task setComputed UBound n(2^(1/n) − 1)Missed deadlines in simulationResult measured on the board
Box 3 Watchdog test record (timeout set, how the task was hung, how the reset showed)

Questions

  1. 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?

  2. 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?

  3. 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.

  4. 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

CLO2 Program GPIO, timers and interrupts. CLO1 Explain microcontroller and embedded architecture. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack