reading 24bit with I2S on nucleo stm32f411re

Guest #4560224
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?

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.