The I2S Loopback Example demonstrates how to take advantage of the I2S driver when creating an application that uses the Inter-IC Sound (I2S) peripheral. It uses a loopback to check that data is transmitted and received correctly. To complete the loopback, the pins configured as the SDOUT and SDIN lines of the I2S peripheral must be wired together.
Data transfers consisting of a specified number of blocks are continuously performed with 500 ms delays between them. The number of blocks is specified by BLOCKS_TO_TRANSFER. The length of each block is half the size of the used memory buffer.
LED 1 and LED 2 are used to visualize the transfers. One of the LEDs is constantly off and the other one is toggled after each transferred block, thus it is blinking at a pace corresponding to the size of the buffer and the used sampling frequency. As long as the data is transferred correctly, LED 1 is toggled. If an error occurs, the toggling is switched to LED 2 until the end of the transfer. This blinking scheme makes it easy to check the correctness of the transfers. Additionally, messages are output on UART.
The following messages indicate successful transfers:
1: OK 2: OK 3: OK ...
Messages similar to the following one indicate an error:
1: 0000/0000, expected: cafd/caff
The first pair of values shows the values of the samples that were received (for the left channel / for the right channel). The second pair shows the values of the samples that were sent.
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\i2s
Hardware configuration:
The default pin assignments for the SDOUT and SDIN lines (I2S_CONFIG_SDOUT_PIN and I2S_CONFIG_SDIN_PIN) can be found in sdk_config.h
.
Test the I2S Loopback Example application by performing the following steps: