cancel
Showing results for 
Search instead for 
Did you mean: 

how to send a int32 with HAL_I2SEx_TransmitReceive_DMA

leogarberoglio
Associate III
Posted on August 07, 2015 at 18:13

Hello, I'm using I2S interface of my 411RE uC. I nee to send some int32 (positive and negative number) becouse my codec expect int32 format. But HAL_I2SEx_TransmitReceive_DMA expect unsigned number. So how do I do to send signed integer using that HAL function?

Regards!
2 REPLIES 2
Posted on August 07, 2015 at 18:50

Doesn't it want uint16_t pointers?

Understand that the STM32 hardware doesn't care what the 8-bit bytes represent.

You might need to be concerned about the endian/interleaving expectations at the end-points, but as far as the function's concerned cast the pointers, and express the size in units of the expected units. ie an int32_t is going to need 2x uint16_t

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
leogarberoglio
Associate III
Posted on August 08, 2015 at 15:05

yes, it expect uint16_t pointer.

let me see if I understand. 

I define a buffer:

int16_t OutputBuffer[1000];

int16_t InputBuffer[1000];

then I cast yhe buffer to uint16_t:

HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t *)OutputBuffer, (uint16_t *)InputBuffer, BufferSize);

that should work ok, right?

now in 32 bits:

int32_t OutputBuffer[500];

int32_t InputBuffer[500];

then I cast yhe buffer to uint16_t:

HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t *)OutputBuffer, (uint16_t *)InputBuffer, BufferSize);

is that ok? am I  missing something? If I configure Data Frame Format on 32bits data on 32 bits frame the hal driver should make 2 transfer (16 bit each) before toggle WS signal, right?

thank clive!