cancel
Showing results for 
Search instead for 
Did you mean: 

.wav player based on STM32F407 using internal DAC

konrad23
Associate
Posted on August 30, 2015 at 20:03

Hi, as specified in the topic, I'm trying to create my own wave file player using f4-discovery board. I've managed to configure the DAC, read the file, find the data section, read the samples and I can hear the sound, but it's full of noise. I can hear very clearly the high tones, such as flute and guitarre, but the rest sound frequencies are distorted. There is almost no bass.

The files have 2 channels, with 16bit samples and sample rate 44100Hz.

I use both channels of DAC, using 12bit left aligned registers and conversion triggered by TIM7. The samples before conversion are increased by 32768 in order to get an unsigned value.  The output buffers are turned on. The output is driving an external amplifier which drives headphones.

I've tried to use the Li-Poly battery to power the board and its still the same. I've checked if the sample buffer is filled faster then the currently used buffer and it is.  I don't have an oscilloscope at hand so I can't tell anything more. Do I do anything wrong or it's hardware fault?

Here's my code:

DAC triggering timer IRQHandler:

http://pastebin.com/CTh1r4X9

DAC configuration: (params: dac_dual_channel_simultanous, dac_trigger_tim7, true)

http://pastebin.com/NwqDr5rA

Thanks in advance for any reply.

#dac #stm32f4-discovery
1 REPLY 1
Posted on August 30, 2015 at 21:47

Doing it one sample at a time with a bunch of modulus operations doesn't seem at all efficient. Surely you could send a block of data as a 32-bit pair directly to the DACs in one operation via DMA, with the DAC triggered by a TIM. Fill the buffer half at a time during the HT and TC interrupts.

Suggest you do it without the file system, send a sine-wave form of various frequencies and confirm that seems to perform as expected.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..