Pseudonymous engineer iwatake has released the code for a spectrum analyzer that runs on the Raspberry Pi Pico, making full use of the dual-core Arm Cortex-M0+ in the RP2040 microcontroller.
Released earlier this year, the Raspberry Pi Pico's RP2040 microcontroller is surprisingly powerful for a $4 ready-to-run device: Its two Arm Cortex-M0+ cores officially run at speeds of up to 133MHz, though hobbyists have found ways to clock them considerably higher. Iwatake's project, though, relies less on the raw performance and more on being able to run independent code on both cores — to make a functional spectrum analyzer for audio tasks.
"[This is a] dual-core spectrum analyzer on Raspberry Pi Pico," iwatake writes of the project, "[using] ADC [analogue to digital conversion], DMA [direct memory access], IRQ [interrupt request], SPI [serial peripheral interface], Core0 and Core1."
The project, written in C++ using the official Raspberry Pi Pico software development kit (SDK), uses the RP2040's two cores to split the work: Core0 is responsible for running the main thread, handling the touch-sensitive SPI display, reading the ADC input, and storing it in buffers; Core2, meanwhile, is dedicated to calculating a fast Fourier transform (FFT) to display on the screen as a live spectrum.
While the project is functional, iwatake warns there's an issue the root cause of which is currently unknown: "There seems to be a bug," they note, "as [the] system often freeze!"
The project's source code is available on iwatake's GitHub repository, under the permissive Apache 2.0 license.