My starting point is the Audio Standalone application example for the STM3240G_Eval board.
It is a 2 channel USB soundcard with stereo 16bit, 48KHz parameters.
First I had to port the application to my STM32F4 Discovery board.
– I changed the processor type from STM32F407IG to t STM32F407VG in the project, and changed the 25MHz clock to 8MHz.
– I changed the USE_STM324xG_Eval to USE_STM32F4_DISCO in the Define section
– I changed the BSP packages in the project and also changed the include path from the original board to mine.
– I don’t need the STMPE811 touch controller so I removed this from the component files
– I used LED3-6 instead of the original board LED1-4
– I configured ST-Link as the debugger, and added the correct STM32F4xx Flash 1MB partition to the Flash Download settings.
– The Discovery board BSP uses SPI so I added the SPI HAL driver to the project and uncommented it in stm32f4xx_hal_conf.h
– In the same file I modified the original 25MHz clock to 8 MHz in #define HSE_VALUE
– I generated a new SystemClock_Config function with STM32Cube MX, for 168MHz and proper PLL settings and replaced the original.
– Discovery is using I2S3 port instead of I2S2 sothe interrupt functions had to be renamed, and also some data structures have different names as you can see.
- extern I2S_HandleTypeDef haudio_i2s;
+ extern I2S_HandleTypeDef hAudioOutI2s;
- void AUDIO_I2Sx_DMAx_IRQHandler(void)
+ void I2S3_IRQHandler(void)
- void AUDIO_I2Sx_DMAx_IRQHandler(void);
+ void I2S3_IRQHandler(void);
– For now I’m not using SRAM, FSMC, UART HAL drivers so I removed them from the project.
After this modifications, my USB soundcard started to work, but there were problems with the playback speed. I read the CS43L22 I2S DAC datasheet about the configuration, and played with STM32Cube MX I2S clock config part. There was something wrong with the I2S Init in the stm32f4_doscovery_audio.c file. I googled a bit and I found the corrected file in the ST Forum, uploaded by an ST engineer, which correct the Init function’s clock configuraton.
– I changed the mentioned file to the new one, and the audio started to work properly.
Now I have the working Audio Streaming on my Discovery board. High Five!