030: Multi-Processing

It's tricky to handle the audio and the potentiometers – both time-sensitive tasks – with one processor.  We've been pausing every 256 audio samples to handle the user interface, which works okay, but requires that we pay attention and not wait too long before returning to the audio, lest we underrun the I2S write buffer.

Fortunately, the RP2040 has a built-in solution: a second processor.  We'll dedicate that processor to handling the audio sample data, and use the first processor for the user interface.

Here is PicoADKChirpPots modified to use the second processor:



That change was almost too easy.  A professional piece of code would use the existing inter-processor buffers and semaphores that are built into the RP2040 hardware, but in truth, since the data flow is always from the UI processor to the audio processor, simply cutting the tasks up and relying on shared memory works well enough.

Copyright © 2024 The President and Fellows of Harvard College * Accessibility * Support * Request Access * Terms of Use