Right of Way
FreeRTOS Task Priority Exercise
Task
At a busy junction, the controller sends its morning traffic count to a console. The report takes about 175 ms to print. When a fire engine's siren is heard, every light must turn red at once to give the fire engine right of way, report or no report.
Write the two FreeRTOS tasks, and choose their priorities so a siren never waits for the report: report task: prints the report once with print_report(); siren task: calls all_red() each time wait_siren() returns. The FreeRTOS calls for this are xTaskCreate, vTaskStartScheduler and vTaskDelete; the Reference tab shows each one.
Circuit
Pass condition
The eight report lines print whole and in order. PA5 goes high within 2 ms and low again within 7 ms of each siren.
Notes
The siren detector raises PA0 for 2 ms per siren while your program runs, during the report. Leave the given code as is. FreeRTOS V11.1.0 is preemptive with a 1 ms tick. A task with a higher priority number runs as soon as it is ready.