port by Thomas Friedrichsmeier
Tested on a STM32F103C8T6 blue pill board as well as an STM32F411CE black pill board, i.e. on sboards without a real DAC. Compiles and runs, with a bunch of caveats (see below). Should probably run on any other board supported by the STM32duino core (although this theory is untested). When trying any other board, you probably want to check the platform specific settings (see below), carefully, importantly, whether the desired output resolution is achievable, and whether the desired output pins are PWM capable.
The following audio modes (see MOZZI_AUDIO_MODE) are currently supported on this hardware:
The default mode is MOZZI_OUTPUT_PWM .
Standard pulse width modulated output to one (mono) or two (stereo, see MOZZI_AUDIO_CHANNELS) GPIO pins. Default pinout: PA8 (mono/left), PA9 (right channel in stereo). This mode uses two hardware timers: One for the PWM (Timer 3 when using the default pin configuration), and a second for updating the output at audio rate. The default audio resolution is 10 bits, which results in a carrier frequency of ~70kHz on a 72MHz CPU. On slower boards you will have to descrease this. The following settings may be costumized, if desired:
This mode is very similar to MOZZI_OUTPUT_PWM, but splitting output for a single channel across two GPIO pins for better resolution. For details on the required hardware setup, and configuration tradeoffs, see MOZZI_OUTPUT_2PIN_PWM . Stereo output is not available in this mode. Output is at 2*7 bits at up to 560kHz carrier frequency (but limited to 5 times audio rate).
Customizable configuration options:
See External audio output . The (single) hardware timer claimed for MOZZI_OUTPUT_EXTERNAL_TIMED may be configured using "MOZZI_AUDIO_UPDATE_TIMER" (default: TIM2).