STM32F4 Endianess and 24 bit data
Hi, trying to get I2S working with 24 bit data. The function call HAL_I2S_Transmit takes a pointer to unsigned 16 bit var so there needs to be 2 transfers to get 24 bits into the I2S. I am using an unsigned 32 bit var and putting the 24 bit value into it, left justified. When the HAL driver unpacks the 32 bit data it does so backwards. Example:
thisData = 0x12345678;
uint16_t *pData = (uint16_t *) &thisData; uint16_t data1 = (*pData++); uint16_t data2 = (*pData++);data1 gets the lower 16 bits: 0x5678
data2 gets the upper 16 bits: 0x1234I need to take a 24 bit number and put it into a 32 bit variable, left justified, and send a 16 bit pointer to the HAL I2S function. How do I do this? What am I missing?
Thanks!
#endianness