Quite some time ago, I started to look into the STM32F411 Discovery Kit with Arduino. Unfortunatly the audio codec i2c address was not showing up in the port scan. I found out that the chip needs to be activated with

setPinMode(PD4, OUTPUT);
digitalWrite(PD4, HIGH);

One of the reasons why I started my arduino-audio-driver project, was that I wanted to have a clean API for the LQFP100 audio chip that is provided by this board. So I added driver logic and the following pin definitions to the project:

    // add i2c codec pins: scl, sda, port, frequency
    addI2C(PinFunction::CODEC, PB6, PB9);
    // add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
    addI2S(PinFunction::CODEC, PC7, PC10, PA4, PC3, PC12);

    // add other pins
    addPin(PinFunction::KEY, PA0, PinLogic::Output);     // user button
    addPin(PinFunction::LED, PD12, PinLogic::Output, 0); // green
    addPin(PinFunction::LED, PD5, PinLogic::Output, 1);  // red
    addPin(PinFunction::LED, PD13, PinLogic::Output, 2); // orange
    addPin(PinFunction::LED, PD14, PinLogic::Output, 3); // red
    addPin(PinFunction::LED, PD15, PinLogic::Output, 4); // blue
    addPin(PinFunction::PA, PD4, PinLogic::Output); // reset pin (active high)

I finally managed to to have this piece working. Here is the Arduino Sketch which sets up the audio chip with the default settings (44100 samples per second, 16 bits) – because no parameter have been defined:

#include "AudioBoard.h"

AudioBoard board(STM32F411Disco); // CS43l22

void setup() {
  LOGLEVEL_AUDIODRIVER = AudioDriverDebug;
  Serial.begin(115200);
  while(!Serial);
  Serial.println("setup...");

  board.begin();

  Serial.println("board has started");
}

void loop() {}

And here is the related output

22:09:33.495 -> setup...
22:09:33.495 -> Debug:   AudioBoard::begin
22:09:33.495 -> Debug:   DriverPins::begin
22:09:33.495 -> Debug:   pinMode 192
22:09:33.495 -> Debug:   pinMode 59
22:09:33.495 -> Debug:   pinMode 52
22:09:33.495 -> Debug:   pinMode 60
22:09:33.495 -> Debug:   pinMode 61
22:09:33.495 -> Debug:   pinMode 62
22:09:33.495 -> Debug:   pinMode 51
22:09:33.495 -> Debug:   PinsI2C::begin for 7
22:09:33.495 -> Info:    setting up I2C scl: 22, sda: 25
22:09:33.495 -> Info:    Setting i2c clock: 100000
22:09:33.495 -> Debug:   AudioDriverCS43l22Class::begin
22:09:33.495 -> Info:    setPAPower pin 51 -> 1
22:09:33.497 -> Debug:   cs43l22_Init
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x2 value=0x1
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x4 value=0xAA
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x5 value=0x81
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x6 value=0x4
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x20 value=0x18
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x21 value=0x18
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0xF value=0x6
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x24 value=0x0
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x25 value=0x0
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0xA value=0x0
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0xE value=0x4
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x27 value=0x0
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x1F value=0xF
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x1A value=0xA
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x1B value=0xA
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x20 value=0x18
22:09:33.497 -> Debug:   i2c_bus_write_bytes: addr=0x94 reglen=1 datalen=1 - reg=0x21 value=0x18
22:09:33.497 -> board has started

As the next step I just have to work on the I2S support for this board


1 Comment

Dane · 12. February 2024 at 15:48

Awesome! These are great boards. Thanks for the continued updates Phil.

Leave a Reply

Avatar placeholder

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