C1255 of 55
0 XP
  1. Hook
  2. Problems

C12 · Final exam

Final exam: embedded systems in MicroPython and C

Twelve problems from the whole course: the board and its registers, C for small machines, memory, inputs, debouncing, timers, interrupts and capture, analog in and out, fixed point and filtering, driving loads, serial buses and protocols, state machines and preemptive scheduling, real time, watchdogs, power, flash storage, control loops, and the two languages. The board runs at 10 MHz, one instruction per cycle. Give yourself three hours, work without the lessons open, and write out your reasoning before checking each answer. "Another set" deals a different exam.

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 fclk/(2⋅CLKDIV)) 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.

Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.

Practice

Keep practicing

16 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.