@Pavel_Hernandez I have modified the example code, any corrections?
void I2S_init(void)
{
FLEXCOMM_Init(I2S7, FLEXCOMM_PERIPH_I2S_TX);
/* protocol: i2s
* sampleRate: 48K
* bitwidth:16
* masterSlave = kI2S_MasterSlaveNormalMaster;
* mode = kI2S_ModeI2sClassic;
* rightLow = false;
* leftJust = false;
* pdmData = false;
* sckPol = false;
* wsPol = false;
* divider = 1;
* oneChannel = false;
* dataLength = 16;
* frameLength = 32;
* position = 0;
* watermark = 4;
* txEmptyZero = true;
* pack48 = false;
*/
/*****************************************************************************
* 2:3 Channel Pair selection
* 4:5 Mode Selection
* 16:19 Data length selection
*****************************************************************************/
I2S7->CFG1 = 0<<2 | 0<<3 | 1<<4 | 1<<5 | 1<<16 | 1<<17 | 1<<18 | 1<<19;
/*****************************************************************************
* 0:7 Frame length selection
*****************************************************************************/
I2S7->CFG2 = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5;
/*****************************************************************************
* 0:7 Clock divider selection
*****************************************************************************/
I2S7->DIV = 0x6f;//0X2f; //0x6f - proper value
/*****************************************************************************
* 0 Transmit FIFO enabled
* 2 Tx FIFO becomes empty
* 5 Data length is less then 16 bit
*****************************************************************************/
I2S7->FIFOCFG = 1<<0 | 1<<2 | 1<<5;
/*****************************************************************************
* 0 Interrupt is generated for an transmission
*****************************************************************************/
I2S7->FIFOTRIG = 1<<0 | 1<<10;
/*****************************************************************************
* 0 Disable Tx error interrupt
* 2 Tx value level specifier
*****************************************************************************/
I2S7->FIFOINTENCLR = 1<<0 | 1<<2;
}
void WM8904(void)
{
codec_config_t boardCodecConfig = {.codecDevType = kCODEC_WM8904, .codecDevConfig = &wm8904Config};
codec_handle_t codecHandle;
CODEC_Init(&codecHandle, &boardCodecConfig);
/* Initial volume kept low for hearing safety. */
/* Adjust it to your needs, 0x0006 for -51 dB, 0x0039 for 0 dB etc. */
CODEC_SetVolume(&codecHandle, kCODEC_PlayChannelHeadphoneLeft , 0x0039);
}