cancel
Showing results for 
Search instead for 
Did you mean: 

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

GChen.5
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
MMuba.1
Associate

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.

View solution in original post

4 REPLIES 4
GChen.5
Associate II

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
Associate

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.

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?

Finally, I managed to make it right, the Frame Synchro Offset of SAI-A didn't match the SAI-B's settings. It should be 'Before First Bit'.

And the amplitude problem is caused by the input volume of wm8994.