C12 Embedded systems in MicroPython and C · Practice
Sound with PWM
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's the frequency of MIDI note 60?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
What PWM PERIOD comes closest to 523 Hz on the 10 MHz board?
Check
What frequency does PERIOD = 22727 make?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A note meant to be 440 Hz plays at 445 Hz. How many cents off is it?
Check
At 90 beats per minute, how long is a note of 1 beats?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A 440 Hz square wave: at what frequency is its harmonic number 3?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
Play MIDI note N (64) on the speaker on PWM channel 2, as a 50% square wave. (The frequency table is up to you: compute it, or hard-code it.)
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
A timer toggles a buzzer pin on each wrap to play 440 Hz.
(a)
What TOP (with PRESCALE = 0, nearest)?
(b)
What frequency actually plays?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A tune is written at 96 beats per minute, a quarter note per beat.
(a)
How long is a quarter note?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
How long is a dotted quarter (one and a half beats)?
Check
Frequency of MIDI note 62?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
PERIOD for 440 Hz?
Check
Length of a 0.5-beat note at 100 BPM?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
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