Skip to main content
sincoon
Associate III
November 28, 2019
Question

Use I2S in DMA mode(STM32f401 + PCM5102A)

  • November 28, 2019
  • 1 reply
  • 2413 views

I want to send audiodata from STM32f401 MCU to PCM5102A audio codec through I2S interface. Here are my settings in CubeMX:

0690X00000AsYOyQAN.png

0690X00000AsZeEQAV.png

Code I used is:

const uint16_t wavedata[] = { /* Random data, length 1024 */ };
 
void beep_blocking()
{
 HAL_I2S_Transmit(&hi2s2, wavedata, sizeof(wavedata)/sizeof(wavedata[0]), HAL_MAX_DELAY);
}
 
void beep_dma()
{
 //__HAL_DMA_ENABLE(&hdma_spi2_tx); // No difference
 HAL_I2S_Transmit_DMA(&hi2s2, wavedata, sizeof(wavedata)/sizeof(wavedata[0]));
}

When I use beep_blocking() function - everything is ok and I hear small peace of noise. But when I use beep_dma() function - nothing happens. What I am doing wrong?

P.S. I do not want to use this as "beep" actually, I want to send data continuously. This is just a test.

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
November 28, 2019

I2S is not intended to be used intermittently; the idea is, that clocks and data are there continuously. Some I2S chips expect that and upon seeing intermittent clock, they stop working or work in an unexpected way.

Observe the I2S pins using oscilloscope and/or LA.

JW