1.1.6.2 I2SC Peripheral Library Help

This section provides an interface to use the Inter-IC Sound Controller (I2SC) peripheral.

Introduction

This library provides a brief overview of the I2SC peripheral.

Description

The I2SC module implements an I2S (Inter-IC Sound) interface, for connection between an MCU and an audio peripheral such as a codec or Bluetooth module.

The I2SC module provides support to the audio protocol functionality via four standard I/O pins. The four pins that make up the audio protocol interface modes are:

  • DI: Serial Data Input for receiving sample digital audio data (ADCDAT)

  • DO: Serial Data Output for transmitting digital audio data (DACDAT)

  • CK: Serial Clock, also known as bit clock (BCLK)

  • WS: Word Select, also known as Left/Right Channel Clock (LRCK)

The BCLK provides the clock required to drive the data out or into the module, while the LRCK provides the synchronization of the frame based on the protocol mode selected.

In Host mode, the module generates both the BCLK on the CK pin and the LRCK on the WS pin. In certain devices, while in Client mode, the module receives these two clocks from its I2S partner, which is operating in Host mode.

When configured in Host mode, the leading edge of CK and the LRCK are driven out within one SCK period of starting the audio protocol. Serial data is shifted in or out with timings determined by the protocol mode set.

In Client mode, the peripheral drives zeros out DO, but does not transmit the contents of the transmit FIFO until it sees the leading edge of the LRCK, after which time it starts receiving data.

Host Mode

Host Generating its Own Clock – Output BCLK and LRCK

Client Mode

Codec Device as Host Derives MCLK from MCU Reference Clock Out

Audio Formats

The I2SC Module supports just one audio format, I2S. Left Justified format is not available.

Using the Library

Configuring the Library

This section describes how to configure the peripheral library using the MHC.

Description

The library is configured for the supported processor when the processor is chosen in MPLAB X IDE, using the Microchip Harmony Configurator (MHC).

Choose the I2SC peripheral by clicking on the appropriate instance under Peripherals->I2SC in the Available Components section of MHC. (The I2SC component may also be added automatically as a result of using a BSP Template, such as one for a codec or Bluetooth module).

When the I2SCx peripheral is clicked on in the Project Graph, the following menu is displayed in the Configurations Options (example shown for instance I2SC1):

Default values are shown. The DMA and Interrupt Mode are always enabled.

Host/Client Mode can be either Host -- the I2SC peripheral supplies the I2S clocks, or Client -- the peripheral such as a codec or Bluetooth module supplies the I2S clocks.

Data Word Length can be selected from 8 to 32-bits.

Data Format is currently always I2S.

Receiver Stereo/Mono can be either Stereo or Mono (left channel duplicated to right).

# of DMA Channels for Receiver can either Single or Multiple (1/channel).

Loopback Test Mode can be Normal or Loop mode.

Transmitter Stereo/Mono can be either Stereo or Mono (left channel duplicated to right).

Transmit Data When Underrun can be Transmit 0 or Transmit previous.

Slot Width can be 24 or 32-bits wide.

The following options are only shown if the Host/Client mode is Host:

Selected Clock for IMCK Ratio is selectable as any integer

• Host Clock to Sample Rate Ratio can be set from 32 to 2048

Host Clock Mode can be either Host Clock Generated or not

Using the Library

This topic describes the basic architecture of the I2SC Peripheral Library and provides information and examples on how to use it.

Abstraction Model

The I2SC module sits between the I2S Driver, and the actual hardware.

Interface Header File: plib_i2sc.h

The interface to the I2SC Peripheral Library is defined in the plib_i2sc.h header file. Any C language source (.c) file that uses the I2SC Peripheral Library should include plib_i2sc.h.

Library Source Files:

The I2SC Peripheral Library library source files are provided in the csp/peripheral/i2sc_xxxx/src or csp/peripheral/i2sc_xxxx/templates directory. This folder may contain optional files and alternate implementations. Please refer to Configuring the Library for instructions on how to select optional features.

Usage Model

The only usage model for the I2SC Peripheral Library is to use a Interrupt/DMA model. Therefore the remaining functions normally associated with a PLIB like this (handling write or read requests, or returning transfer status), will be accomplished by the I2S driver directly communicating with the appropriate DMA functions, which is why they are not provided here.

The one function provided besides initialization is one for synchronizing with the left/right clock (LRCLK) for the I2S stream.

Example Applications:

This library is used by the following applications, among others:

  • audio/apps/audio_tone

  • audio/apps/audio_tone_linkeddma

  • audio/apps/microphone_loopback

Library Interface

This section describes the Application Programming Interface (API) functions of the Peripheral Library.

Refer to each section for a detailed description.

  • Initialization Function

NameDescription
I2SCx_InitializeInitializes I2SCx module of the device
  • Transaction Function

NameDescription
I2SCx_LRCLK_GetGet the level of the I2S LRCLK (left/right clock) signal