In my last post, I was describing that I started to work on adding I2S audio support to the STM32F411 Discovery Board.

I finally have my Arduino I2S library that supports the STM32F411 Blackpill and Disovery Board ready. I was completely redesigning the old, mostly generated C library into some C++ classes and I have now a better way to support additional boards.

Unfortunately I still don’t have any clean sound on my Discovery Board: Software Development is not easy!

Arduino Test Sketch

I can use the regular sine generator test sketch that has been written for the AudioKit and is using my flexible driver library. I just need to replace the board and use STM32F411Disco.

#include "AudioTools.h"
#include "AudioLibs/AudioBoardStream.h"

AudioInfo info(44100, 2, 16);
SineWaveGenerator<int16_t> sineWave(32000);                // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave);             // Stream generated from sine wave
AudioBoardStream out(STM32F411Disco);
StreamCopy copier(out, sound);                             // copies sound into i2s

// Arduino Setup
void setup(void) {  
  // Open Serial 
  AudioLogger::instance().begin(Serial, AudioLogger::Info);

  // start I2S
  Serial.println("starting I2S...");
  auto config = out.defaultConfig(TX_MODE);
  if (!out.begin(config)){

  // Setup sine wave
  sineWave.begin(info, N_B4);

// Arduino loop - copy sound to out 
void loop() {

So I was checking the I2S pins with an oscilloscope and they look good. Here is output of the clock and data pins:

The good news is that the data output to the pins seems to work!

But initially I was not getting any tone: So the issue needs to be with the integration and initialization of the audio chip!

And I was right: The codec provides a cs43l22_Play method which needs to be called to activate the output. After integrating this into my driver, I am getting some audio output: but unfortunately not the expected clean sine tone (yet).

So this will be my next task…



Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *