C12 Embedded systems in MicroPython and C · Practice
SPI: shift registers and displays
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
This board's SPI clock is . What's the SPI clock with CLKDIV = 2?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Check
How long does it take to clock 4 bytes over SPI at 1 MHz?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
Segments a to g are bits 0 to 6. Light exactly the segments that show the digit 3. What byte is that, in hex?
Check
How many output pins do 2 daisy-chained 8-bit shift registers give?
Check
SPI sends 5B most significant bit first. What level is the 1th bit on MOSI?
Check
Show the digit D (4) on the seven-segment display: CS is P13 (active low, latching on its rise), and the byte goes over SPI.
C on the course's RISC-V board (10 MHz, no floating point). #include "board.h" for the registers; print(x) shows a number. Tab indents; press Esc and then Tab to move on.
Check
Eight LEDs hang off the shift register (bit 0 is the bottom LED). Light the bottom 3 of them, as a level meter would.
MicroPython on the course's board: machine (Pin, PWM, ADC, DAC, UART, I2C, SPI, Timer, WDT) and time. Each call into the hardware takes about 40 µs. Tab indents; press Esc and then Tab to move on.
Check
An SPI transfer of 16 bits runs at 1 MHz.
(a)
How long does it take?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
(b)
How many transfers a second could it make back to back?
Check
4 daisy-chained 8-bit shift registers are updated over SPI at 1 MHz.
(a)
How long does one update take?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
(b)
How many clock pulses is that?
Check
SPI clock with CLKDIV 4?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
Check
Time for 2 bytes at 2 MHz?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
Outputs from 4 chained shift registers?
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