Hi there,
I need assistance with a driver or a detailed explanation on how to use I2S in TDM mode. Based on the user manual, there aren't many registers available, and I'm having trouble distinguishing it from DSP mode. The instructions for configuring this peripheral in TDM mode are quite vague.
For my use case, I need TDM with 4, 8, or 16 channels. I attempted to configure it using the MCUXConfig utility, but it didn't produce the results I was looking for. I need a simple I2S data line configuration where each channel is 16 bits wide and placed consecutively. For example, the data would be stored for TDM 4 in the following format:
int16_t sine_480_arr[100] __attribute__((aligned(4)))= {0x0000, 0x0809, 0x100A, 0x17FB, 0x1FD4, 0x278D, 0x2F1E, ...};
int16_t sine_960_arr[100] __attribute__((aligned(4)))= {0x0000, 0x100A, 0x1FD4, 0x2F1E, 0x3DA9, 0x4B3B, 0x579E, ...};
int16_t sine_1920_arr[100] __attribute__((aligned(4)))= {0x0000, 0x1FD4, 0x3DA9, 0x579E, 0x6C12, 0x79BB, 0x7FBE, ...};
int16_t sine_3840_arr[100] __attribute__((aligned(4)))= {0x0000, 0x3DA9, 0x6C12, 0x7FBE, 0x73D0, 0x4B3B, .... };
uint8_t comb_sine[800] __attribute__((aligned(4)))= {0};
// main()
for (size_t i = 0, p = 0; i < 800; p++, i+=8)
{
comb_sine[i+0] = sine_960_arr[p] & 0xFF;
comb_sine[i+1] = sine_960_arr[p] >> 8;
comb_sine[i+2] = sine_3840_arr[p] & 0xFF;
comb_sine[i+3] = sine_3840_arr[p] >> 8;
comb_sine[i+4] = sine_480_arr[p] & 0xFF;
comb_sine[i+5] = sine_480_arr[p] >> 8;
comb_sine[i+6] = sine_1920_arr[p] & 0xFF;
comb_sine[i+7] = sine_1920_arr[p] >> 8;
}
s_TxTransfer.data = &comb_sine[0];
s_TxTransfer.dataSize = sizeof(comb_sine);
I2S_TxTransferSendDMA(FLEXCOMM2_PERIPHERAL, &FLEXCOMM2_Tx_DMA_Handle, s_TxTransfer);
I2S_TxTransferSendDMA(FLEXCOMM2_PERIPHERAL, &FLEXCOMM2_Tx_DMA_Handle, s_TxTransfer);
Any asist would be appreciated,
Best regards