2018-10-16 11:34 PM
I am using STM32f407VG Discovery for audio application. I am having a problem while using the I2S2 in Slave Receive mode using the HAL_I2S_DMA_Receive() for receiving 16-bit data on a 32-bit frame. I am able to get the Audio data correctly at times and the audio transmitted using I2S3 plays without any noise. But at other times, the sync between the WS and SD seems to get disturbed. The received data in the buffer is shifted (with 0 appended on the last 24 of the 32 bits). Simply resetting the STM32f407VG Discovery results in different behaviour each time.
When the audio is clear, the buffer receives 16-bit of data while when audio is noisy, the buffer data is appended with zeroes and the higher order bits seem to get lost due to improper sync with the WS.
Even removing the WS on receiver side once the audio has started playing doesn't stop the audio data from playing!
Here is my code:
uint16_t music1[64];
volatile uint8_t buf_tx=0,flag_tx=0;
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
{
if(hi2s->Instance==SPI2)
{
buf_tx=32;
flag_tx=1;
}
}
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
{
if(hi2s->Instance==SPI2)
{
buf_tx=0;
flag_tx=1;
}
}
int main()
{MX_GPIO_Init();
MX_DMA_Init();
MX_I2S2_Init();
MX_I2S3_Init();
flag_tx=0;
flag_stream=1;
HAL_I2S_Receive_DMA(&hi2s2,music1,64);
while (1)
{
while(flag_tx==0);
flag_tx=0;
HAL_I2S_Transmit(&hi2s3,&music1[buf_tx],32,5000);
}
}
Solved! Go to Solution.
2018-10-17 01:28 AM
The I2S/SPI in 'F40x uses only the first edge of WS for synchronization, it does not resynchronize after that. And, you have to wait for the proper "inactive" level of WS before enabling I2S - see the I2S-related errata .
JW
2018-10-17 01:28 AM
The I2S/SPI in 'F40x uses only the first edge of WS for synchronization, it does not resynchronize after that. And, you have to wait for the proper "inactive" level of WS before enabling I2S - see the I2S-related errata .
JW
2019-04-10 01:55 AM
Thanks. This solved the issue.