2026-01-05 5:34 AM
Hi,
I want to design a voice announcement system using the STM32F103C8T6.
My requirement is to Load WAV audio files from an SD card and play them using the STM32, without using any external DAC.
I would like guidance on how to start the project using STM32CubeMX / STM32CubeIDE, including:
Peripheral configuration in CubeMX
Audio playback method without a DAC (for example, PWM-based audio)
Basic coding structure to read WAV files from an SD card and play them
Any help or reference projects would be greatly appreciated.
I have design hardware also here attachment is there please go through it ...Thank you
Solved! Go to Solution.
2026-01-06 12:05 AM
@itrajusankar The examples given by @MOBEJ refer to an external audio DAC, which would also be possible with an STM32F103. However, apart from the schematics, you have not provided many details so far, neither that it is an genuine STM32F103 and not one of the many counterfeits, nor the expected maximum audio frequency, nor an explanation of what you mean by ‘not as good as expected’ in the result.
We can only speculate at this point and assume that you are using TIM4 as a PWM output on PB6 and PB8, correct?
I must also assume that you are generating an internal frequency of 72MHz from the HSE=8MHz. Your low-pass filter of 1k+100nF, which you have on each of the two PWM outputs, has a cut-off frequency of 1591Hz, which could be suitable for subwoofers at best. For reasonably good audio quality (which also needs to be defined first), I assume a minimum PWM resolution of 14 bits. With these parameters, we can already estimate the result: 72MHz/16384 ~ 4394Hz, which is extremely attenuated by the low-pass filter – this cannot produce a meaningful result.
Regards
/Peter
2026-01-06 2:19 AM - edited 2026-01-06 2:22 AM
Hi,
why not F303 ? has DAC ... and about same price + pinout.
2026-01-06 10:29 PM
> For reasonably good audio quality (which also needs to be defined first), ...
About 5kHz audio frequency (which means twice the sampling frequency) is usually considered sufficient for good speech comprehension. I would choose the standard sampling rate of 11250Hz.
2026-01-07 2:54 AM
Indeed, 4kH is (was?) considered "toll quality" for telephone lines...
2026-01-07 4:01 AM
And the average for AM-based radio. Good old times ...
2026-01-07 4:52 AM
But back to the topic ...
The STM32F100C8 does have a DAC.
Many other STM32 variants as well.
And there are relatively cheap external DACs with a serial interface (e.g. SPI).
I think using e.g. PWM instead of a DAC is saving on the wrong things.
One needs to take the subsequent audio PA stages into consideration as well, and PWM would create a lot of undesired harmonics that need to be filtered out.