TrueSTUDIO 9.0.1 + STM32CubeMX + PCM5102 I2S DAC example

Download stm32 + pcm5102 example source code here (937kb)

Just made a quick test to connect PCM5102 module to STM32F407VET6 board through I2S interface.

First, I downloaded and installed latest version of CubeMX. I changed default position of I2S pins as shown on the image below:

First, audioBuffer array is filled with two sinusoidal tones of 1KHz and 2KHz. Then HAL_I2S_Transmit_DMA is called to run DMA transfer in circular mode.

Although I2S configured as 32/32bit tranfer, I configured DMA transfer as halfword/halfword (16bit) to make it work correctly. It seems that there is a hint in STM’s Reference Manual:

The 24-bit and 32-bit data frames need two CPU read or write operations to/from the SPI_DR or two DMA operations if the DMA is preferred for the application. For 24-bit data frame specifically, the 8 nonsignificant bits are extended to 32 bits with 0-bits (by hardware)

Leave a Reply

Your email address will not be published. Required fields are marked *