SPH0645_I2S_Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-27 12:51 AM
I am using STM32F407VG in my project temporarily. The objective is to transmit audio data over ethernet which is received in this mic and received audio from the other end this side having stm32 as the MCU.
For Mic, I am using SPH0645. But I am unable to sample the audio correctly. I am facing the same issue as in the following link.
https://community.st.com/t5/stm32-mcus-products/unexpected-behaviors-in-dma-buffer-for-i2s-mems-microphone/td-p/725679
my_code:
uint16_t data_in[100] = { 0 };
volatile int16_t sample_i2s;
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) {
sample_i2s = data_in[0];
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2S2_Init();
/* USER CODE BEGIN 2 */
HAL_I2S_Receive_DMA(&hi2s2,(uint16_t*)&data_in[0],100);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
i am unable to read the I2S audio buffer properly.
The output when i plot the variable "sample_i2s" is
Note:
STM32F407VG board is chosen just because it has I2S pins. For transferring via the Ethernet, I am going to use STM32F767ZI and I am using this Discovery board for time being. So if anyone have a solution, Kindly do reply in the same thread.
Thank You.
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-04 2:55 AM - edited 2025-04-04 2:57 AM
Since I am using STM32F407VG Discovery board which has an on-board mic, the issue is resolved after removing this on-board mic and the results are proper when using the I2S bus that concern this on-board Mic. It is not the issue that concern SPH0645 Mic. Use the I2S Line that is connected with the on-board Mic after removing and interface with the I2S mic which is SPh0645.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-30 11:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-31 3:00 AM
Glancing over it, the output plot seems to suggest a data size issue somewhere.
Every other data item zero point to a systematic issue.
I don't have the hardware either, nor do I use Cube.
> i am unable to read the I2S audio buffer properly.
I think you talk about the F4 discovery board here, which came with SPL examples that make use of the CS43L22 audio codec.
Perhaps you can compare the relevant code, especially initialisation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-31 4:54 AM
@mbarg.1 Thank you for the reply!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-31 4:56 AM
Thank you for the reply.!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-03-31 5:06 AM
You set the DMA on word,32b, but from my experience the F4 i2s is not working correctly then. So try settings with half word, 16b, and also the data in int16 .
The i2S working correctly then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-01 3:47 AM
@AScha.3 Will try and update you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-01 4:21 AM
@AScha.3 wrote:So try settings with half word, 16b, and also the data in int16 .
Same results!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-04 2:55 AM - edited 2025-04-04 2:57 AM
Since I am using STM32F407VG Discovery board which has an on-board mic, the issue is resolved after removing this on-board mic and the results are proper when using the I2S bus that concern this on-board Mic. It is not the issue that concern SPH0645 Mic. Use the I2S Line that is connected with the on-board Mic after removing and interface with the I2S mic which is SPh0645.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-04-04 5:41 PM
Glad you have solved your problem. I've done a fair bit of experimenting with the SPH0645. If you have trouble with a large (and varying) DC offset in the data from the microphone, perhaps give the TDK T5848 I2S microphone a try - I've been very impressed with its performance and features - although the maximum supply voltage of 2V is a bit of a nuisance.
