0% found this document useful (0 votes)
70 views20 pages

CS43L22 Codec Documentation

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views20 pages

CS43L22 Codec Documentation

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Tutored Project

CS43L22 Codec Documentation

Submitted by:
Ahmed Omrani
Hadil Guedri

Advisor: Ms. Wided Souidene

11.10.2024 (V1.0)
CS43L22 Codec Documentation V1.0 11.10.2024

Contents

Contents I

1 Introduction 1

2 Overview of CS43L22 2
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 CS43L22 pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Communication between stm32f4 discovery and CS43L22 11


3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 I²C protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 I²S protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.4 GPIO pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.5 Configuration commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4 Conclusion 14

Bibliography 15

List of Figures 16

List of Tables 17

Acronyms 18

Ahmed Omrani Hadil Guedri I


CS43L22 Codec Documentation V1.0 11.10.2024

1 Introduction
The STM32F4 Discovery is a development board based on the STM32F407VG microcontroller
from STMicroelectronics and features an Arm® Cortex®-M4 core. Among its many other
features, the board incorporates an integrated audio codec, CS43L22, which makes it possi-
ble to process audio information for both recording and playback. The Cirrus Logic CS43L22
codec is designed to perform stereo digital-to-analog conversion and is used for portable de-
vices maximizing the quality of audio projects on this platform. The report talks about the
CS43L22 codec incorporated in the development board of STM32F4 Discovery that is built
around STM32F407VG microcontroller. Cirrus Logic’s low power, high performance stereo
DAC known as CS43L22 is designed for audio devices with headphone and class-D speaker
amplifiers, as well as DSP based tone control and beeping. Important characteristics of the
codec include 16 to 24 bit digital to analog converter, any sample rate between 8khz to 48khz
and an i2s and i2c interface which allows transmission of data and control to the STM32F4
microcontroller seamlessly. To perform such activities as audio playback, audio recording and
audio configuration control, the STM32F4 microcontroller can take advantage of these inter-
faces making it suitable for the embedded audio applications. With the addition of the CS43L22
codec, this audio module expands the capabilities of the STM32F4 Discovery board to an entire
range of audio applications from simple audio playback to complex audio effects generation,
and some codes used for the audio modules setup and configuration are provided in this report.

Ahmed Omrani Hadil Guedri 1


CS43L22 Codec Documentation V1.0 11.10.2024

2 Overview of CS43L22

2.1 Introduction
This chapter explores the architecture of the CS43L22, the role of its DSP engine, and the
configuration of its analog and digital outputs. Key features, such as analog passthrough and
pin characteristics, are detailed to give a thorough understanding of how this device can be
incorporated into systems that require audio output with minimal power consumption. This
examination of the CS43L22’s general architecture sets the stage for subsequent discussions on
its communication protocols and how it interfaces with microcontrollers like the STM32F4.

2.2 Architecture

Figure 2.1: CS43L22 Architecture

The CS43L22 is a compact, low-power audio DAC designed for portable systems that require
high-quality sound while conserving energy. This audio DAC integrates several powerful fea-
tures optimized for both performance and efficiency in portable audio applications. [1]
At its core, the CS43L22 incorporates a Digital Signal Processing (DSP) engine that
allows for advanced audio controls. These include bass and treble adjustments across various
frequencies, enabling precise audio tuning for enhanced sound quality. Volume can be smoothly
adjusted through digital controls with soft ramping transitions, and analog controls are designed

Ahmed Omrani Hadil Guedri 2


CS43L22 Codec Documentation V1.0 11.10.2024

to apply changes only at zero-crossing points of the audio waveform to avoid pops and clicks.
Additional DSP capabilities include de-emphasis, a limiter that prevents audio distortion at
high volumes, and a beep generator that can produce tones over a two-octave range, useful
for alerts or notifications [1]
The CS43L22 includes a stereo headphone amplifier powered from a separate positive sup-
ply, while an integrated charge pump provides a negative supply. This configuration enables a
ground-centered output with a wide signal swing, eliminating the need for external DC-blocking
capacitors. The Class D stereo speaker amplifier adds further efficiency, delivering high-
quality output without requiring an external filter. This design not only conserves battery life
but also allows direct battery-powered operation. The device’s internal battery monitoring
and compensation system ensures steady audio levels even as battery voltage declines, a
critical feature for portable systems.[1]
The DAC operates using a multi-bit delta-sigma architecture, which oversamples audio
at 128 times the system’s primary sample rate, enhancing audio fidelity while keeping power
consumption low. The CS43L22 also supports analog passthrough, which routes analog
input directly to the headphone amplifier. This feature is valuable in applications such as FM
tuners, where audio received over the air can be directed straight to the headphones without
additional processing. [1]
Additionally, the CS43L22 provides features for battery level monitoring and temperature
management, which contribute to its reliability in portable applications. These monitoring
systems ensure consistent audio output across different conditions and add a layer of safety by
adjusting output levels as battery power fluctuates. [1]
With its combination of high-performance audio capabilities, energy efficiency, and compact
design, the CS43L22 is an excellent choice for portable audio projects that demand both quality
and flexibility.
With this general overview of the CS43L22’s architecture, we have examined its core function-
alities. Now, let’s delve into some of its components in greater detail.[1]

2.2.1 DSP engine

The CS43L22 features a fixed-function DSP (Digital Signal Processing) engine that efficiently
handles key audio processing tasks while maintaining low power consumption. This engine
primarily works with PCM (Pulse Code Modulation) serial input data and includes several
useful features:

• Independent volume control: This allows for separate volume adjustments for the left
and right audio channels.[1][1]

Ahmed Omrani Hadil Guedri 3


CS43L22 Codec Documentation V1.0 11.10.2024

Figure 2.2: DSP Engine Signal Flow

• Channel manipulation: The DSP engine can swap the left and right audio channels or
combine them into a mono output, giving flexibility for different audio setups.[1]

• Tone control: It offers bass and treble adjustments, allowing users to fine-tune the audio
for clearer sound quality.

• Limiter function: The DSP includes a limiter that automatically adjusts the volume
to prevent distortion, especially useful during high-volume playback.[1][1]

• Beep generator: This feature produces sounds across a two-octave range with indepen-
dent volume control, making it ideal for notifications or alerts.[1]

These functions are integrated into the DSP, as shown in the architecture diagram, which also
demonstrates how it works alongside volume control, tone adjustments, channel manipulation,
and dynamic range management via the limiter (CS43L22).[1]

2.2.2 Analog passthrough


The Analog Passthrough feature in the CS43L22 codec routes the analog input signal directly
to the headphone amplifiers, which is beneficial in applications like FM tuners where audio
needs to be transmitted directly to the headphones without interference from digital processing
stages. This passthrough path helps reduce power consumption and eliminates noise that can
arise from digital modulation.[1]
The CS43L22 allows selection or combination of four different analog input channels via the
PASSxSEL bits. In passthrough mode, a pair of amplifiers can be used to mute and apply

Ahmed Omrani Hadil Guedri 4


CS43L22 Codec Documentation V1.0 11.10.2024

volume adjustments to these input signals. This feature gives flexibility for input channel
control and enables direct analog signal management within the codec.[1]

Figure 2.3: Analog Passthrough Signal Flow

Ahmed Omrani Hadil Guedri 5


CS43L22 Codec Documentation V1.0 11.10.2024

2.2.3 Analog outputs

Figure 2.4: Analog Outputs

The diagram on page 25 of the CS43L22 datasheet, labeled ”Analog Outputs,” provides a de-
tailed view of the analog output stages, including the left and right headphone outputs and
associated controls. This section connects the digital signal processing (DSP) engine to the
headphone amplifiers (HPA and HPB) and supports direct analog passthrough (PASSTHRUx)
for routing audio signals straight to the amplifiers without digital conversion. Key controls
include headphone mute (HPxMUTE) and adjustable volume (HPxVOL[7:0]) and gain (HP-
GAIN[2:0]). The analog passthrough function offers additional flexibility, allowing external
analog signals to bypass DSP and route directly to the headphone amplifier with volume ad-
justments available through the PASSxVOL[7:0] control, which offers a range from +12 dB to
-60 dB in 0.5 dB steps. These adjustable controls support clear and flexible audio output for
various applications, ensuring optimal quality across different use cases.[1]

2.3 CS43L22 pins


2.3.1 Pin descriptions
The CS43L22 audio DAC offers a wide range of functionalities for digital and analog interfacing.
This document provides a summary of the pin descriptions and input/output characteristics as
outlined in the CS43L22 datasheet.[1]

Ahmed Omrani Hadil Guedri 6


CS43L22 Codec Documentation V1.0 11.10.2024

Figure 2.5: CS43L22 Pins’ Placements

Ahmed Omrani Hadil Guedri 7


CS43L22 Codec Documentation V1.0 11.10.2024

Pin Name Pin Number(s) Description


SDA 1 Serial Control Data: Data I/O in I²C mode.
SCL 2 Serial Control Port Clock: Provides the serial clock
in the I²C control mode.
AD0 3 Address Bit 0 for I²C: Sets the least significant bit
of the I²C address.
SPKR OUTA+/- 4, 6 PWM Speaker Output: Differential output for the
A channel speaker.
SPKR OUTB+/- 7, 9 PWM Speaker Output: Differential output for the
B channel speaker.
VP 5, 8 Power for PWM Drivers: Supplies the power for
the PWM output driver stages.
-VHPFILT 10 Inverting Charge Pump Filter: Provides the nega-
tive rail for headphone/line amplifiers.
FLYN 11 Charge Pump Cap Negative Node: Negative side
of the charge pump capacitor.
FLYP 12 Charge Pump Cap Positive Node: Positive side of
the charge pump capacitor.
+VHP 13 Positive Analog Power for Headphone: Supplies
power for internal headphone amplifiers.
HP/LINE OUTA, B 14, 15 Headphone/Line Level Audio Output: Stereo
headphone or line-level output.
VA 16 Analog Power: Provides positive power for the
analog circuitry.
AGND 17 Analog Ground: Ground reference for analog sec-
tion.
FILT+ 18 Positive Voltage Reference: Used for internal sam-
pling circuits.
VQ 19 Quiescent Voltage: Reference voltage for internal
circuitry.
TSTO 20, 36 Test Output: Used for testing purposes; must be
left floating.

Table 2.1: CS43L22 Pin Descriptions (Part 1)

Ahmed Omrani Hadil Guedri 8


CS43L22 Codec Documentation V1.0 11.10.2024

Pin Name Pin Number(s) Description


AIN4A, B; AIN3A, B; AIN2A, B; AIN1A, B 21, 22, 23, 24, 25, 26, 29, 30 Line-Level Analog Inputs: Provide single-ended
stereo line-level inputs for the A and B channels.
AFILTA, AFILTB 27, 28 Anti-Alias Filter Connection: Connections for the
analog passthrough anti-alias filter.
SPKR/HP 31 Speaker/Headphone Switch: Controls the power
states for speaker and headphone outputs.
RESET 32 Reset: Places the device in low-power mode when
held low.
VL 33 Digital Interface Power: Determines the signal
level for serial audio and control ports.
VD 34 Digital Power: Provides positive power for the dig-
ital section.
DGND 35 Digital Ground: Ground reference for digital sec-
tion.
MCLK 37 Master Clock: Source clock for delta-sigma modu-
lators.
SCLK 38 Serial Clock: Serial clock for the audio interface.
SDIN 39 Serial Audio Data Input: Input for two’s comple-
ment serial audio data.
LRCK 40 Left Right Clock: Specifies the active audio chan-
nel.
GND/Thermal Pad - Provides ground reference for power transistors
and aids in thermal dissipation.

Table 2.2: CS43L22 Pin Descriptions (Part 2)

2.3.2 I/O characteristics


The I/O pin characteristics define the operational voltage and current ranges for the various
pins. These values ensure compatibility with the digital and analog systems interfaced with the
CS43L22. The table below summarizes the typical I/O characteristics.[1]

Ahmed Omrani Hadil Guedri 9


CS43L22 Codec Documentation V1.0 11.10.2024

Parameter Min Typ Max


Input Leakage Current - - ±10 µA
Input Capacitance - - 10 pF
High-Level Output Voltage VL - 0.2 V - -
Low-Level Output Voltage - - 0.2 V
High-Level Input Voltage (VL = 1.65 V) 0.85 × VL - -
Low-Level Input Voltage (VL = 1.65 V) - - 0.3 × VL

Table 2.3: I/O Characteristics of CS43L22

2.4 Conclusion
To conclude, the CS43L22 audio codec is a versatile and high-performance component that
enables superior sound quality in portable systems, balancing advanced digital processing with
low power consumption. Through its integrated DSP engine, the CS43L22 offers enhanced
audio controls like volume adjustment, tone tuning, and audio channel manipulation, allowing
for precise and customized audio output. Its analog passthrough feature and efficient ampli-
fier design contribute to optimal battery conservation, making it particularly well-suited for
portable audio applications.
By understanding the general architecture, DSP functionalities, analog passthrough capabili-
ties, and the detailed I/O characteristics of the CS43L22, developers gain a comprehensive view
of how this codec can be effectively integrated into system designs. This chapter has provided
an in-depth examination of the CS43L22’s core features and functions, setting the stage for sub-
sequent chapters that will delve into its communication protocols and configuration commands
in tandem with the STM32F4 Discovery board. Through these protocols, the codec’s advanced
capabilities are harnessed, allowing it to convert digital audio data into rich, high-quality sound
tailored for specific applications.

Ahmed Omrani Hadil Guedri 10


CS43L22 Codec Documentation V1.0 11.10.2024

3 Communication between stm32f4 discovery and


CS43L22

3.1 Introduction
The STM32F4 Discovery board communicates with the CS43L22 audio codec using the I²C
and I²S protocols, with additional control through GPIO pins. This document provides an
overview of this communication process.

3.2 I²C protocol

Figure 3.1: IC2 bus with a single master and 3 slaves

The I²C (Inter-Integrated Circuit) protocol is a synchronous, multi-master, multi-slave,


packet-switched, single-ended, serial communication bus. It allows microcontrollers to commu-
nicate with peripheral devices using only two wires: a data line (SDA) and a clock line (SCL).
In this setup, the STM32F4 uses I²C to send configuration commands to the CS43L22 codec,
setting parameters like power management, audio format, and volume.[1][2]

3.3 I²S protocol


The I²S (Inter-IC Sound) protocol is a serial bus designed specifically for transferring digital
audio data. It requires three main lines:

• SD (Serial Data): Carries the digital audio data.[3]

• WS (Word Select): Indicates the channel (left or right) of the audio data.[3]

Ahmed Omrani Hadil Guedri 11


CS43L22 Codec Documentation V1.0 11.10.2024

• SCK (Serial Clock): Synchronizes the transmission.[3]

On the STM32F4 Discovery board, the I²S interface transfers audio data from the STM32F4
to the CS43L22 codec, which then converts this digital data into an analog audio signal.[3]

Figure 3.2: Data transmission with I2S protocol

3.4 GPIO pins


Several GPIO pins on the STM32F4 are used to manage the state of the CS43L22:

• Reset Pin (RESET): A GPIO pin (often configured as PD4) is used to reset the
codec.[4]

• I²S Data: Audio data is transmitted over the I²S protocol via the STM32F4’s dedicated
I²S peripheral, which connects to the codec’s audio data input.[4]

3.5 Configuration commands


Through the I²C interface, the STM32F4 can send register values to the CS43L22, setting
parameters such as:

• Audio sample rate[4]

• Output volume[4]

• Power states[4]

3.6 Conclusion
In summary, the STM32F4 Discovery board communicates with the CS43L22 codec as follows:

Ahmed Omrani Hadil Guedri 12


CS43L22 Codec Documentation V1.0 11.10.2024

• I²C is used for configuration.

• I²S is used for audio data transfer.

• GPIO is used for additional control, such as resetting the codec.

Ahmed Omrani Hadil Guedri 13


CS43L22 Codec Documentation V1.0 11.10.2024

4 Conclusion
In conclusion, the CS43L22 audio codec is a powerful and efficient solution for portable audio
applications, offering high-quality sound output with minimal power consumption. Its inte-
grated Digital Signal Processing (DSP) engine provides versatile features such as volume and
tone control, audio channel manipulation, and a limiter to ensure distortion-free audio. The
analog passthrough capability further enhances its flexibility, making it an excellent choice for
systems that prioritize battery life while maintaining superior audio performance. By under-
standing its general architecture, DSP functionalities, and I/O characteristics, developers can
fully leverage the CS43L22 in embedded audio systems. The subsequent chapters will explore
how to configure and communicate with this codec using protocols like I²C and I²S, ensuring
seamless integration with microcontrollers such as the STM32F4, and enabling the full potential
of the CS43L22 in real-world applications.

Ahmed Omrani Hadil Guedri 14


CS43L22 Codec Documentation V1.0 11.10.2024

Bibliography
[1] C. Logic, “Cs43l22 low power stereo dac with headphone and speaker amplifiers.” Available
at https://www.cirrus.com (Accessed on 2024/11/11).

[2] microcontrollerslab, “I2c communication protocol basics.” Available at https://


microcontrollerslab.com/i2c-bus-communication-protocol-tutorial-applications/
(Accessed on 2024/11/11).

[3] D.-K. Electronics, “What is the i2s communication protocol?.” Available at https://www.
digikey.com/en/maker/tutorials/2023/what-is-the-i2s-communication-protocol
(Accessed on 2024/11/11).

[4] STMicroelectronics, “Discovery kit for stm32f407/417 lines.” Available at https://www.


st.com (Accessed on 2024/11/11).

Ahmed Omrani Hadil Guedri 15


CS43L22 Codec Documentation V1.0 11.10.2024

List of Figures

2.1 CS43L22 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2


2.2 DSP Engine Signal Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Analog Passthrough Signal Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Analog Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 CS43L22 Pins’ Placements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.1 IC2 bus with a single master and 3 slaves . . . . . . . . . . . . . . . . . . . . . . 11


3.2 Data transmission with I2S protocol . . . . . . . . . . . . . . . . . . . . . . . . 12

Ahmed Omrani Hadil Guedri 16


CS43L22 Codec Documentation V1.0 11.10.2024

List of Tables

2.1 CS43L22 Pin Descriptions (Part 1) . . . . . . . . . . . . . . . . . . . . . . . . . 8


2.2 CS43L22 Pin Descriptions (Part 2) . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 I/O Characteristics of CS43L22 . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Ahmed Omrani Hadil Guedri 17


CS43L22 Codec Documentation V1.0 11.10.2024

Acronyms
CS43L22 Audio Codec Model

DSP Digital Signal Processing

PCM Pulse Code Modulation

I²C Inter-Integrated Circuit

I²S Inter-IC Sound

GPIO General Purpose Input/Output

FM Frequency Modulation

dB Decibels

Ahmed Omrani Hadil Guedri 18

You might also like