C12 Embedded systems in MicroPython and C · Practice
Final exam
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
An LED with forward voltage 1.9 V is driven from 3.3 V through 100 Ω, with PWM at 60% duty.
(a)
What current flows while it's on?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
(b)
What's its average current?
Check
A register byte holds 6E.
(a)
What does it hold after setting bit 2, in hex?
(b)
What's its upper 4-bit field, in hex?
Check
A 22 kΩ pull-up charges 40 pF; separately, a button bouncing 4 times each way is pressed 6 times.
(a)
How long until a released pin reads high? (kΩ × pF = ns)
Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.
(b)
How many falling edges does an undebounced counter see?
Check
A timer has PRESCALE = 99, TOP = 999; separately, an ISR of 900 cycles fires 50 thousand times a second.
(a)
How long between wraps?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
What share of the processor does the ISR use?
Check
A thermistor divider (10 kΩ at 25 °C, B = 3950, over 10 kΩ) gives 1.8 V.
(a)
What code does the 12-bit ADC report?
(b)
What temperature is it?
Check
A value 2.75 is stored with 10 fraction bits; separately, the ADC reads 3707.
(a)
What integer stores 2.75?
(b)
What does (c * 3300 + 2047) / 4095 give?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A buzzer plays MIDI note 66; separately, a DAC plays a 32-sample table at 32000 Hz.
(a)
What PWM PERIOD plays the note?
(b)
What frequency does the table play?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A UART runs at 115200 baud.
(a)
What BAUDDIV?
(b)
How long do 30 bytes take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
Bytes arrive at 115200 baud while the main loop may be away for 4 ms; its ring buffer has head 140 and tail 100.
(a)
How many bytes can arrive meanwhile?
(b)
How many bytes are waiting now?
Check
An I²C device answers at 50; a transaction sends 6 bytes at 100 kHz, plus about two clocks.
(a)
What's the first byte of a read, in hex?
(b)
How long does the transaction take?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
An SPI bus (clock ) updates 2 chained shift registers; separately, a frame's payload is 180, 150, 70.
(a)
How long does one update take on the wire?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
(b)
What's the payload's 8-bit sum checksum?
Check
A superloop runs task 1 (0.4 ms every 5 ms) and task 2 (40 ms every 1000 ms).
(a)
What's the utilization?
(b)
How late can task 1 start, at worst, because of task 2?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A 100 Hz, 1 V signal is sampled with 40 µs of jitter; separately, a job has latency 90 µs, execution 100 µs and deadline 200 µs.
(a)
How large can a sample's error be?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
(b)
What's the job's margin?
Check
A watchdog gets a 3× margin over an 8 ms longest pass; separately, a device is awake 5% of the time at 2 mA and asleep at 0.5 mA.
(a)
What WDT_LOAD?
(b)
What's the average current?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
Check
A room (2000 J/°C, R = 0.02 °C/W, outside 0 °C) has a 1000 W heater; its thermostat's band is ±1 °C, warming and cooling at 0.3 and 0.3 °C/s.
(a)
Where would it settle with the heater always on?
(b)
How long is one on-off cycle?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
Check
A device logs 64-byte records 24 times a day in a 4 KB flash sector rated for 10000 erases. Its control loop samples every 5 ms against a plant with a 20 ms time constant.
(a)
How long does the log's sector last?
(b)
What is the loop's largest stable proportional gain (plant gain 1)?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C12