cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 I2S with DMA connected to Audio Codec, converting long to float

koster
Associate III
Posted on August 19, 2013 at 13:54

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.

cheers

mig

#stm32f4-i2s-dma-24bit-codec
3 REPLIES 3
Posted on August 19, 2013 at 14:11

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).

JW

schen44
Associate
Posted on February 12, 2015 at 02:52

I am working with a similar project using 24 bit audio codec. Could you please share your code? Thanks.

Posted on February 12, 2015 at 10:06

Have a look at the I2S examples in the Standard Peripheral Library, start from there and modify it to your particular application.

JW