cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429 and pcm1808 some I2s question

Igor1
Associate

Hello. Please help me.

I want to use pcm1808 ADC in 24bit mode. pcm1808 have a two channels, left and right. I'm generate some code in CubeMX and send recv data to pcm5102 DAC. The sound is transmitted to both channels. But I need to take only the left channel from the ADC .

Now i take 16bit RX_buffer[4] buffer from recieve and bring it to 16bit TX_buffer[4] transmit buffer, when HAL_I2S_RxCpltCallback occurce.

DMA is in circular mode. after init periph i'm start dma

HAL_I2S_Receive_DMA(&hi2s3, RX_buffer, 4);

 HAL_I2S_Transmit_DMA(&hi2s2, TX_buffer, 4);

But i dont understand how can i take from ADC 24bit data from left channel and 24bit from right channel. Im tried to do

uint_32 Left_channel_Data = (RX_buffer[0]<<16) | RX_buffer[1]; in HAL_I2S_RxHalfCpltCallback and

uint_32 Right_channel_Data = (RX_buffer[2]<<16) | RX_buffer[3]; in HAL_I2S_RxCpltCallback

But data is wrong.

My task is to transmit data over the network by UDP from one device to another. in First device i would like to use two different audio signals from ADC and then play it in a second one. UDP data transfer, work fine. Thank you and sorry for my English!

2 REPLIES 2
Igor1
Associate

In fact I cant understand how to use HAL_Driver with i2s in 32 bit mode.

In function HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); *pData is 16bit, but needed data is 32bit. if i use Size = 4 i'm think that first two of uint16_t bytes (pData[0] fnd pData[1]) must contain Left_channel data from ADC, third and fourth of uint16_t bytes (pData[2] fnd pData[3]) must contain Right_channel data from ADC. And HAL_I2S_RxHalfCpltCallback  occurs when firs 2 16bit data recv.

> But data is wrong.

How exactly wrong?

The significant 24-bit are in the MSB of the resulting 32-bit value, so maybe you might want to right-shift them by 8, if you want to store/transfer them as 24-bit.

Also, interrupts have significant overhead on entry/exit, so are you sure your software can pull data fast enough from the short buffer, so that it won't be overrun by the subsequent data during processing? Toggle a GPIO upon interrupt entry/exit and measure.

JW

PS Please change your username to a normal nick.