EmbDev.net

Forum: µC & Digital Electronics reading 24bit with I2S on nucleo stm32f411re


von Mike (Guest)


Rate this post
useful
not useful
Hello,

I am new to microcontroller programming. I am trying to read a digital 
microphone with a 24bit i2s interface. My problem is that the results I 
get are just uint16_t thus I loose some bits.
I'm using st cube and HAL. The api documentation is:
1
/**
2
  * @brief Receive an amount of data in blocking mode 
3
  * @param  hi2s: pointer to a I2S_HandleTypeDef structure that contains
4
  *         the configuration information for I2S module
5
  * @param pData: a 16-bit pointer to data buffer.
6
  * @param Size: number of data sample to be sent:
7
  * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
8
  *       configuration phase, the Size parameter means the number of 16-bit data length 
9
  *       in the transaction and when a 24-bit data frame or a 32-bit data frame is selected 
10
  *       the Size parameter means the number of 16-bit data length. 
11
  * @param Timeout: Timeout duration
12
  * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization 
13
  *       between Master and Slave(example: audio streaming).
14
  * @note In I2S Master Receiver mode, just after enabling the peripheral the clock will be generate
15
  *       in continuous way and as the I2S is not disabled at the end of the I2S transaction.
16
  * @retval HAL status
17
  */
18
HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
I tried
1
uint16_t I2S_RX_BUFFER2[24];
2
 HAL_I2S_Receive(&hi2s1, (uint16_t*)I2S_RX_BUFFER2, 24, 0x1000);
My i2s is initialized for 24bit MSB first. How can I get 24bit results?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.