Audio Output with the STM32F411 Microcontroller

I obtained an STM32F411 development board recently. Among other peripherals, it has a Cirrus CS43L22 audio DAC on the board and a typical 1/8" adapter allowing you to plug in headphones or typical PC speakers as shown below.

STM32F411 Connected to Speakers

Searching the web, I found a couple of code examples using audio with the STM32F411 board, however, they either used STM's HAL or Standard Peripheral Library. These API's are great for rapid development and cross-product compatibility but they can make it difficult to understand exactly how the MCU is configured.

I rewrote one example I found so that it operates without relying on an intermediate library between my code and the MCU's registers. I also changed it to output a sine wave instead of a sawtooth. With a sine tone, I find it's easier to hear abnormalities (as well as see them with an oscilloscope).

The code, which is well commented explaining how/why it works, can be found on GitHub here. Any questions, just let me know - contact info here.

Date: October 18th, 2017 at 7:04pm
Author: Terence Darwen
Tags: Embedded, STM32, STM32F4, ARM-Cortex-M4, CS43L22, Audio

Previous Next