2013-08-19 04:54 AM
Hi,
I have the I2S running on STM32F4 with DMA and Interrupt connected to a 24 bit AD/DA codec, which works fine. I receive/transmit the 64 bit frame based on 4 DMA transfers between SPIx->DR and Memory.Unfortunately the order of the Hi and Lo short (16 bit) is vice versa and I need to exchange the 16 Bit values to get a 32 bit Long, containing the 24 bit Audio in a correct order, to convert them via 'vcvt.s32.f32' and 'vcvt.f32.s32' to float and back.Is there a possiblity to receive/transmit the 16 bit values in a correct order, without manually exchanging them? I'm not sure if the DMA FIFO could be an option, or how to configure this function correctly.cheersmig #stm32f4-i2s-dma-24bit-codec2013-08-19 05:11 AM
No. The DMA used in STM32s is rather dumb and does not support endian swap of any kind.
Fortunately, the ARM core implements barrel shift (maybe except the Cortex-M0(+), which is not the case here), i.e. halfword swap is only one instruction (in ''true'' ARMs (i.e. non-Thumb), it would be probably zero, as barrel shifts there are generally performed as part of other instructions, e.g. memory load). OTOH, you might find out that you need a full endian swap, i.e to swap the order of bytes in the word. Luckily, there's a single instruction in ARM for that, too (REV). JW2015-02-11 05:52 PM
I am working with a similar project using 24 bit audio codec. Could you please share your code? Thanks.
2015-02-12 01:06 AM
Have a look at the I2S examples in the Standard Peripheral Library, start from there and modify it to your particular application.
JW