2014-09-07 11:46 PM
I downloaded STM32CubeF4 package here, and I can't find a USB Speaker (or USB Audio Standalone) application at:
STM32Cube_FW_F4_V1.3.0\Projects\STM32F4-Discovery
So what I did was use:
STM32Cube_FW_F4_V1.3.0\Projects\STM324xG_EVAL\Applications\USB_Device\AUDIO_Standalone
... as reference, since it's meant to be tailored among STM32F407x/STM32F417x devices and it is configured to use the same CS43L22 DAC which the STM32F4Discovery uses.
Basically, I want STM32F4Discovery to act as a USB Speaker when it's connected to a Host PC, by having this audio flow:
[PC] --USB Device IN--> [STM32F407x] --I2S OUT--> [CS43L22 DAC] --DAC--> earphones (via CN4)
I just did the following changes:
Step 1. At General Options' Target Device in Project Options, replace:
- ST STM32F407IG
+ ST STM32F407VG
Step 2. Applied this change in main.c
- RCC_OscInit.PLL.PLLM = 25;
+ RCC_OscInit.PLL.PLLM = 8;
RCC_OscInit.PLL.PLLN = 336;
- RCC_OscInit.PLL.PLLP = 2;
+ RCC_OscInit.PLL.PLLP = RCC_PLLP_DIV2;
Step 3. At Drivers/BSP in Project Explorer, replace:
- ''STM324xG_EVAL'' drivers (stm324xg_eval.c, stm324xg_eval_audio.c)
+ ''STM32F4-Discovery'' drivers (stm32f4_discovery.c, stm32f4_discovery_audio.c)
Step 4. At C/C++ Compiler's Preprocessor in Project Options, replace:
- define of USE_STM324xG_EVAL and include directory $PROJ_DIR$\..\..\..\..\..\..\Drivers\BSP\STM324xG_EVAL
+ define of USE_STM32F4_DISCO and include directory $PROJ_DIR$\..\..\..\..\..\..\Drivers\BSP\STM32F4-Discovery
Step 5. Changed all LED references from LED 1-4 to LED 3-6 instead.
Note:
I retained usage of the following, since these should be the same regardless of whether STM32F4Discovery or STM324xG_EVAL board is used:
2014-09-08 02:03 AM
Hi maggie.roxas,
Thank you for the details, that can give us enough insight into what specifically you are doing, and how.Please be patient as we try to reporoduce your issue.Regards.2014-09-08 02:44 AM
Thank you very much for looking into this.
I uploaded the modified ''AUDIO_Standalone''https://app.box.com/s/p77a5kyzoti57v050sqo
. # Please extract at STM32Cube_FW_F4_V1.3.0\Projects\STM324xG_EVAL\Applications\USB_Device. Also attached screenshot of the USB streaming in host PC. Will wait for your feedback, then! ________________ Attachments : screenshot090814.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0RV&d=%2Fa%2F0X0000000bcm%2FMBd4RNfBYHR8gwQFmY_hrCNoW6IgbnGPpCjX4N9THT0&asPdf=false2014-09-09 09:57 AM
Himaggie.roxas,
After investigating your code, and making the appropriate tests on the STM32F4-Discovery board, we suggest the following modifications: stm32f4xx_it.c- extern I2S_HandleTypeDef haudio_i2s;
+ extern I2S_HandleTypeDef hAudioOutI2s;
- void AUDIO_I2Sx_DMAx_IRQHandler(void)
+ void I2S3_IRQHandler(void)
- HAL_DMA_IRQHandler(haudio_i2s.hdmatx);
+ HAL_DMA_IRQHandler(hAudioOutI2s.hdmatx);
stm32f4xx_it.h
- void AUDIO_I2Sx_DMAx_IRQHandler(void);
+ void I2S3_IRQHandler(void);
Your projectnever come to fruition because of the confusion between the Audio OUT configuration of the EVAL/DISCO boards.
It's better to add a breakpoint in theBSP_AUDIO_OUT_Play() API call to ensure that the audio stream playing is starting...
You may have some audio quality limitations. We are working to give you the best configuration.Keep us informed about your finding.
Regards.
2014-09-09 08:34 PM
> After investigating your code, and making the appropriate tests on the STM32F4-Discovery board, we suggest the following modifications:
I did the stm32f4xx_it.c and stm32f4xx_it.h patches you suggested, and finally, after that, I can hear sounds (coming from the host PC) being played in the STM32F4Discovery. :)The quality is not that good though (please see below).In any case, thank you so much for checking on this issue!> Your project never come to fruition because of the confusion between the Audio OUT configuration of the EVAL/DISCO boards.You're right.> You may have some audio quality limitations. We are working to give you the best configuration. Keep us informed about your finding.
Indeed.The music coming out from the disco is a bit slower and low frequency/tone than the one being actually played on the host PC (either via Media Player or through test tone in Sound's speaker configurations).Is it the same on your side?
2014-09-10 01:54 AM
As advised to me, I managed to improve the sound quality by applying further modifications @stm32f4xx_hal_conf.h:
- #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
Sound quality
before above modifications: non-continuous (audible stops), slow timing, low frequency
Sound quality
after above modifications:continuous (non-audible stops), right timing, low frequency
So only the problem on low frequency remains (ie, woman's voice sounds like a man's).
Any ideas?
2014-09-10 05:13 AM
I confirm that you've to make the following changes, because the external oscillator value changes from EVAL to DISCO board:
- #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
+ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
I'm trying to check the root cause of the limitation you've got.Please be patient as we work to fix it.
Regards.
2014-09-10 05:55 AM
> I confirm that you've to make the following changes, because the external oscillator value changes from EVAL to DISCO board:
Yes, indeed.
> I'm trying to check the root cause of the limitation you've got. Please be patient as we work to fix it.Sure! Thank you.
2014-09-10 07:00 AM
Hi,
We have detected a limitation within the BSP_AUDIO_OUT_Init() API, under the Audio driver for the STM32F4-Discovery board (stm32f4_discovery_audio.c) file. We’ll pass it along to our development team. In the meantime, you can run your project with the attached modified file. Thanks for your participation and keep an eye out for the next update! Regards. ________________ Attachments : stm32f4_discovery_audio.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Tl&d=%2Fa%2F0X0000000bcl%2FdJcECX_zZc.mgKBUOoNwub0xRVMgjE65OtiJr1034S4&asPdf=false2014-09-10 07:09 PM
I confirm that I used the modified stm32f4_discovery_audio.c file you attached and verified that sound quality coming from host PC is now OK at STM32F4Discovery board.
Thank you for assisting me on this issue! :)