Dexy Firmware

Firmware for the Dexy module

The Dexy FM voice module is based on an RP2040 microcontroller. The firmware is open source and is published under the MIT license. GitHub repository is here.

Building the Firmware

Compiling the Dexy firmware requires the following tools:

Here are step-by-step instructions for setting up a development environment on Windows using Visual Studio Code.

Instructions for installing the toolchain on Linux and Mac OS can be found in Getting Started with Raspberry Pi Pico.

Firmware Overview

The Dexy firmware is responsible for:

The firmware is written in C++ using the Raspberry Pi Pico C/C++ SDK. The Dexy module uses an Adafruit KB2040 board but the firmware can run on a Raspberry Pi Pico or other compatible board; my prototype used an Adafruit Feather RP2040. To use a different RP2040 board, the I/O pin definitions in Gpio.h must be changed (and of course the PCB layout must be modified).

The RP2040 microcontroller has two CPU cores, and the Dexy firmware uses both of them.

Core 0 reads the CV inputs (at the sample rate, called from an interrupt) and also runs a task scheduler that executes various lower-priority tasks such as patch selection and USB communication.

Core 1 runs the FM synthesis algorithm to generate audio output samples and sends the output to the DAC chip. Audio output is generated at a sample rate of 49152 Hz, clocked by a PWM timer interrupt.

The firmware stores 32 preset patches. The rotary encoder is used to select which patch to play. There is no patch editing on the module - patches are editing using the DexyPatch software and downloaded to the module. Downloaded patches are stored in flash memory so they are retained when the module is turned off. Note: Updating the firmware will replace the patches with a default set.

FM Synthesis

The FM synthesis is loosely based on the Yamaha DX7 voice architecture, but only a single voice is implemented. There are 6 operators, each consisting of a sine wave oscillator and an envelope generator. The operators are combined according to one of 32 “algorithms” so that some operators are audio outputs and some operators modulate another operator’s frequency.

Sine waves and envelopes are generated using wavetables.

Notes

It was challenging to get the FM synthesis code to run fast enough to keep up with the 49 kHz sample rate. Here are some notes about performance.

Another challenge was getting accurate results from the 12-bit ADC in the RP2040 so there is good (well, good enough) volt-per-octave pitch tracking across 10 octaves. More info here.

The Dexy firmware does not support pitch tracking (keyboard tracking) for operator amplitude and envelope rate, as the DX7 does. This is a useful feature that may be added in the future.

Tools & Libraries Used