4 ms·
It's pretty easy to do with one core, too - I would guess that the author didn't use interrupts or peripherals because they were writing about MCUs in general r
by mycroftcomptro 5y ago
It's pretty easy to do with one core, too - I would guess that the author didn't use interrupts or peripherals because they were writing about MCUs in general rather than a specific chipset. The K210 they used as an example is actually targeted towards ML applications.
Most chips will have some sort of PWM or advanced timer peripheral that can generate waveforms on a pin without direct CPU intervention. You write to registers to change the frequency, duty cycle, etc.
Many chips also include asynchronous DACs, but they're usually too low-resolution for high-fidelity audio.
Most microcontrollers also include some form of DMA, which can shuttle data between peripherals and memory without CPU intervention. You can also user timer peripherals to trigger DMA transfers, which lets you send buffered data to a DAC on a KHz schedule while the CPU does other things.
And of course, you can usually use timer peripherals to periodically interrupt the main thread when you don't want to wait in a busy-loop.