C12 Embedded systems in MicroPython and C · Practice
The DAC and waveform generation
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
What DAC code gives 1.25 V?
Check
The DAC holds 1000. What's its output?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A 16-sample table is played at 16000 samples per second. What frequency comes out?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
What sample rate plays a 32-sample table at 440 Hz?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A phase accumulator updates 8000 times a second. What 32-bit step makes 440 Hz?
Check
A full-scale 32-entry sine table centered at mid-scale: what's entry 5?
Check
Make the DAC output MV millivolts (1250 mV), as close as its 12 bits allow, using integer arithmetic.
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
In MicroPython, set the DAC to 1.65 V.
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
The 12-bit DAC spans 0 to 3.3 V.
(a)
What code gives 1.2 V?
(b)
What is one step?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A 32-bit phase accumulator updates at 10 kHz.
(a)
What step plays 100 Hz?
(b)
What is its frequency resolution?
Write units the way you normally would: 1.5 mHz, 1500 µHz and 0.0015 Hz are the same answer.
Check
DAC code for 1 V?
Check
Frequency of a 128-sample table at 20000 Hz?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
32-bit DDS step for 1000 Hz at 48000 Hz?
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