An embedded controller must complete a one-time action shortly after a requested deadline. Its completion lateness is the elapsed time from that deadline until the action finishes.
The design uses these timing bounds:
The flag remains set until serviced, and no other delays occur. For this design calculation, add the stated upper bounds to obtain a conservative guarantee, even if particular clock phases could produce a shorter delay.
Calculate the original completion-lateness bound with no optional jobs, the largest whole number of optional jobs per pass that preserves a completion-lateness guarantee of at most 3.50 ms, and the revised bound with that number of jobs. Give both time bounds in ms to two decimal places and the job count as an exact integer.
Unlock full course notes by signing up
Selecting the timer compare value
A 16-bit hardware timer receives an ideal 20.0 MHz clock through a prescaler that divides the clock frequency by 8. Its configured cycle contains one tick at each count from 0 through compare value CCC, inclusive, and then repeats. What compare value produces a 0.800 ms event period?
Clock readings versus physical waiting time
In a microcontroller simulation, a clock has a timing resolution of 4 μs: its reported time changes only in 4 μs steps. The reading is 0 μs at real time 0 μs, becomes 4 μs at real time 4 μs, becomes 8 μs at real time 8 μs, and continues in this pattern. Between updates, the reading remains unchanged.
Let C(t)C(t)C(t) be the clock reading at real time ttt. A custom delay routine saves C(tstart)C(t_{\text{start}})C(tstart) when called. It then checks the clock at the start time and every 1 μs afterward, returning at the first check satisfying
Elapsed time across rollover
A controller uses a 32-bit unsigned millisecond timestamp that wraps modulo 232=42949672962^{32}=4294967296232=4294967296. A scheduled action uses this test, with all three variables declared as the same 32-bit unsigned type:
The saved timestamp is previous = 4294967271, the current timestamp is now = 39, and interval = 60. The true elapsed time since the saved timestamp is less than one full wrap. Which conclusion is correct?
Scheduled references and late execution
Two controllers each initialize previous = 0 and use a 50 ms interval. Both check the following condition only at timestamps 50, 110, 150, and 200 ms:
Policy A updates previous = now. Policy B updates previous += 50UL. All timestamp arithmetic is unsigned, no rollover occurs, each check executes the condition once, and the update and action take negligible time.
Which pair of action histories is correct, and which policy preserves the original 50 ms scheduling grid?