Hopper
FreeRTOS Burst Logging Exercise
Task
At a grain store, a sensor reads a hopper's level each time a load drops in. Loads come in quick bursts. The store's log prints every reading, but slowly, and a reading lost or printed twice puts the records out.
Write the two FreeRTOS tasks and start them, so every reading prints once, in the order it was taken: sampler task, priority 2: takes a reading with read_level() each time wait_strobe() returns; logger task, priority 1: prints each reading with print_reading(n, level), n counting from 1. The FreeRTOS calls for this are xTaskCreate, vTaskStartScheduler, xQueueCreate, xQueueSend and xQueueReceive; the Reference tab shows each one.
Circuit
Pass condition
Every reading, once and in order: two bursts of six print 1 L=3 to 12 L=0.
Notes
The sensor strobes PA4 once per reading while your program runs, in bursts of up to six readings 2 ms apart. A reading's level is on PA0 to PA3 from just before its strobe until the next reading. 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.