About I2S and audio summary

Source: Internet
Author: User
Tags generator

1. Basic knowledge of I2S

1.1 I2s Introduction

I2S bus, the abbreviation Inter-icsound, is a bus standard developed by Philips for audio data transmission between digital audio devices, which is specially used for data transmission between audio devices and is widely used in various multimedia systems. The I2S is also a synchronous serial communication interface.

1.2 i2s the connection line and function

1) Serial clock SCLK, also called the Clock (BCLK), which corresponds to the digital audio of each bit of data, SCLK have 1 pulses. The frequency of the SCLK =2x the sampling frequency x sample number of bits.

2) Frame clock Lrck, (also known as WS), is used to toggle the left and right channel data. A Lrck of "1" indicates that the data being transmitted is the right channel, and "0" indicates that the data being transmitted is the left channel. The frequency of the Lrck equals the sampling frequency.

3) Serial data SDATA0, input data, is a binary complement of audio data, if the half-duplex on a data line.

4) Serial data SDATA1, output data, is a binary complement of audio data, full duplex has two data lines.

5) MCLK, called the Master Clock, also known as the system clock (Sys clock), is 256 times times or 384 times times the sampling frequency. To enable better synchronization between systems

1.3 I2S Audio Standard

Four different audio standards:

1) i2s Philips Standard.

2) MSB alignment standard.

3) LSB alignment standard.

4) PCM standard.

1.4 Frequency calculation

I2S bit rate = number of bits per channel x number of channels x audio sample frequency

2. Comparison of Nordic52840 and STM32F4 series I2s

2.1 Nordic52840 's i2s

Main characteristics of 2.1.1 i2s

1) Simultaneous bi-directional (TX and RX) audio streaming (main note i2s only supports full duplex, 52840 not half-duplex concept)

2) 8, and 24-bit sample width.

3) Low-jitter Master clock Generator (there is a dedicated master clocking MCLK generator).

4) Various Sample Rates

2.1.2 Lrck SCK McK's role links and differences 2.1.2.1 leftright Clock (Lrck)

 

In I2S mode, each frame contains oneleft and right sample pair, with the left sample being transferred during Thelow half Period of Lrck followed by the right, sample being transferred duringthe high period of Lrck.

Lrck always toggles around thefalling edge of the serial clock SCK.

Consequently, the Lrck frequency isequivalent to the audio sample rate (Lrckfrequency corresponds to the sampling frequency of the sound).

Lrck = Mck/config. RATIO

The config.ratio can be set as follows:

2.1.2.2 Serial Clock (SCK)

The serial Clock (SCK), often referred to as the serial bit clock, pulsesonce for each data bit being

Transferred on the serial data lines Sdin and Sdout (one waveform per bit of data).

SCK = 2 * Lrck * CONFIG. Swidth

The config.swidth can be set as follows:

2.1.2.3 Master Clock (MCK)

1) SCK frequency can never exceed the MCK frequency, Whichcan be formulated as:

CONFIG. Ratio>= 2 * CONFIG. Swidth

2) The Mck/lrck ratio shall be a multiple of 2 *config. Swidth, which can be formulated as:

Integer = (CONFIG. RATIO/(2 * CONFIG.) Swidth))

The frequency at which the master clock MCLK can be set

As shown in the figure above MCLK can be set to a range of 0.256mhz-16.0mhz.

Relation between RATIO, MCK and Lrck.

2.2 stm32f4xx 's i2s

The I2S2EXT_SD and I2S3EXT_SD are extended SD pins for control of the I2S full duplex mode.

The SPI can be used as an audio I2S interface when the Enable I2S function (the i2smod position in the SPI_I2SCFGR Register is 1). This interface uses almost the same pins, flags, and interrupts as the SPI.

main characteristics of 2.2.1 I2S

The I2S and SPI share the following three pins:

1) SD: Serial data (mapped to MOSI pin) for sending or receiving data on two time-division multiplexed data channels (half duplex mode only).

2) WS: Word selection (mapped to NSS pin) is the data control signal output in main mode and data control signal input from the mode.

3) CK: Serial clock (mapped to SCK pin), serial clock output in main mode and serial clock input from mode.

The extra 3 pins are as follows:

4) I2S2EXT_SD and I2S3EXT_SD: Additional pins for controlling the I2S full duplex mode (mapped to miso pins). Additional pins can be used when some external audio devices require the use of a master clock output:

5) MCK: When the I2S is configured as the primary mode (and Mckoe position 1 in the SPI_I2SPR Register), this additional clock is output using the master clock (separate mapping), and the clock output frequency is 256xFS, where FS is the audio signal sample frequency.

Other Features:

1) Bit programmable linear prescaler for accurate audio sampling frequency (from 8 khz to 192 khz)

2) data format can be 16-bit, 24-bit or 32-bit

3) The packet frame is fixed by the audio channel to 16 bits (can accommodate 16-bit data frames) or 32-bit (can accommodate 16-bit, 24-bit, 32-bit data frames)

4) The main clock can be output to drive external audio components. Ratio fixed to 256xFS (where FS is the audio sample frequency)

2.2.2 supported audio formats

There are four combinations of data and frame formats that can be used to send data in the following formats:

1) Encapsulating 16-bit data in 16-bit frames

2) Encapsulating 16-bit data in 32-bit frames

3) Encapsulating 24-bit data in 32-bit frames

4) Encapsulating 32-bit data in 32-bit frames

2.2.3 clock generator

As shown in the figure above, the two i2s (I2S2 and I2S3) have a dedicated PLL (PLLI2S) to generate more accurate clocks.

The I2S (I2S2 and I2s3) clocks can be provided by an external clock on the I2s_ckin pin.

3. Industry standards and Fundamentals of audio

3.1 Sampling frequency of audio

In the industry there are three sets of sampling rates coexisting:

1) 44.1kHz and below sampling, sampling: 22.05kHz, 11.025khz,88.2khz, 176.4kHz

2) 48kHz and below sampling, sampling: 24kHz, 12khz,96khz, 192kHz

3) 8kHz, 16kHz, 32kHz, 64kHz 3.2 Audio Trivia

The hearing of the human ear is limited, ranging from 20Hz to 20kHz. According to the Nyquist sampling theorem, the sampling frequency will not produce aliasing as long as it exceeds twice times the signal bandwidth. In the digital media field, such as the Music CD specification, 44.1kHz is used as the standard sampling rate. Since 44.kHz is twice times greater than 20kHz, the actual 44.1kHz sample rate is sufficient.

4. questions and answers about audio

Q: Three sets of sampling standard how to choose.

A: However, it is common to use 48kHz or 96kHz frequency recording in the project, which will only be converted to 44.1kHz CD format when the final mastering is processed, thus reducing the distortion caused by multiple sample rate conversions.

Q: What sampling frequency should be chosen by the Usbaudio plugged into the computer.

A: In the computer field, the AC97 specification as the audio hardware codec standard only stipulates 48kHz.

Q: The commonly used audio device is 12 darker than the feature bit depth or 24 than the feature bit depth.

A: The highest quality standards in the professional recording industry are: 24 bit deep, 192000Hz sampling frequency, referred to as "24bit/192khz () 24-bit Analog input ADC: sample Rate 192kHz". So the normal audio device will choose 12 than the feature bit depth.

Q: Is the MCU as master or slave when communicating with codec?

A: If codec uses external Crystal perk for MCLK, then many professionals recommend the MCU as a slave device. NORDIC52840 has a special clock generator, if the Nordic52840 clock generator to codec to provide MCLK,MCU at this time as slave or master is not much difference, but as Master is better set, Recommended for master devices.

Q: Codec is the use of external crystal oscillator to provide MCLK or use MCU to provide MCLK.

A: The external crystal oscillator may appear with the MCU frequency mismatch phenomenon, resulting in sound distortion. It is recommended to use MCU to provide MCLK.

Q: Does the FULLUSB satisfy the transmission of the audio?

A: The full USB rate is 12MHz, and the bandwidth required for audio is as follows:

I2S bit rate = number of bits per channel x number of channels x audio sample frequency

Play:i2s bit rate = 12x2x48khz= 1152 kHz

Record:i2s bit rate = 12x2x48khz= = 1152 KHz

Full USB rate is 12MHz > (play:i2s bit rate + record:i2s)

Conclusion: Meeting the requirements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.