Question
STM32 HAL Libs I2S 16bit Stereo?
Posted on November 25, 2015 at 21:59
I am confused with the HAL I2S libraries as there does not seem to be support for 16bit stereo (2 channels).
I admit, I am a bit new on I2S but I suspect that with 44100 sampling frequency with two channels of 16 bits each, I need to transfer 32bits per stereo sample to the codec.The HAL Libraries don't seem to support that. The only modes are the following:#define I2S_DATAFORMAT_16B ((uint32_t)0x00000000)#define I2S_DATAFORMAT_16B_EXTENDED ((uint32_t)0x00000001)#define I2S_DATAFORMAT_24B ((uint32_t)0x00000003)#define I2S_DATAFORMAT_32B ((uint32_t)0x00000005)With the DATAFORMAT value providing bits for two fields on the chip:In the reference manual 28.5.8 SPI_I2S configuration register (SPI_I2SCFGR)I find there are two fields related to this: Bits 2:1 DATLEN: Data length to be transferred with values for 16, 24, and 32 bits.andBit 0 CHLEN: Channel length (number of bits per audio channel) with 9 for 16 bit and 1 for 32 bitsIn the the DATAFORMAT values in the HAL Libraries there is no #define fortransfer of 32bits with 16bit channels. i.e. ((uint32_t)0x00000004)What am I missing?On the same issue, using DMA I suspect I need to do a 32bit memory to 2*16 SPI type transfer to get this right.