Skip to main content
GChen.5
Associate II
March 22, 2022
Solved

How to get the audio line-in data from the STM32H735G-DK?

  • March 22, 2022
  • 4 replies
  • 2932 views

I tried the BSP example for H735G-DK, but it doesn't work.

What I want to do is get an audio wave from line_in (the blue audio jack on the board).

The setup for SAI1 is in the picture, I can play the audio through the line out without any problem but can not get the readable waveform data from the line in.

0693W00000Kde20QAB.jpg0693W00000Kde2AQAR.jpg 

uint8_t txData[2] = { 0, 0 };
/* enable the clock by starting the tx */
if (HAL_SAI_Transmit(&hsai_BlockB1, txData, 2, 1000) != HAL_OK)
 Error_Handler();
 
if (audioDrv->Play(audioCompObj) != 0)
 Error_Handler();
if (HAL_SAI_Receive_DMA(&hsai_BlockA1, (uint8_t*)recordBuff, RECORD_BUFFER_SIZE) != HAL_OK) {
 Error_Handler();
}

The audio input is a 2k sin waveform, what I got from SAI1 are:

0693W00000Kde2ZQAR.jpg0693W00000Kde2VQAR.jpgIt does have the 2k frequency peak, but the waveform is far from a sin wave, what could be the problem?

This topic has been closed for replies.
Best answer by MMuba.1

https://www.youtube.com/watch?v=O2XaCFsWxSw

Here is the YouTube video where you can get the audio line-in data from the STM32H735G-DK. If you didn't understand then please contact me here, I'll be very happy to help you.

4 replies

GChen.5
GChen.5Author
Associate II
March 23, 2022

It seems something happened with the first bit of some data. The received values are something like ...,32761,32765,3,8,13,... which should be ...,-7 (32761-32768), -3 (32765 - 32768), 3, 8, 13,...

Even if I modify the value manually, the value seems to be too small, the amplitude is less than 30.

MMuba.1
MMuba.1Best answer
Visitor II
March 23, 2022

https://www.youtube.com/watch?v=O2XaCFsWxSw

Here is the YouTube video where you can get the audio line-in data from the STM32H735G-DK. If you didn't understand then please contact me here, I'll be very happy to help you.

GChen.5
GChen.5Author
Associate II
March 23, 2022

Hi MMuba.1, thanks a lot for your nice tutorial, but I still have the problem that the received value is too small. If I disable the 30 dB gain, the maximum received value would be 30, if I enable the 30 dB gain, the maximum received value is 70.

I expected the value range should be [-32768, 32767], what could be the problem?