STM32F4 Audio Buffer Glitch
Posted: Wed May 10, 2017 8:11 pm
Hi all, i'm fresh new to this forum and relatively new to embedded programming (learning it by myself)
It's been a few months now that i'm stuck on a noise coming out of the jack plug whenever the STM32 Discovery Board is powered on and connected (via the audio jack) to my audio interface, even if the board's output is not routed to the speakers.
This 6kHz noise is related to the audio buffer size, since i'm working with a sample rate of 48kHz and the buffer is 8 elements long, 48000 / 8 = 6000.
I also tried to double the buffer size and as expected the noise frequency fell down by half of its initial value.
I uploaded a reduced version of the source code.
I removed all the unnecessary code to avoid getting you guys lost in what has nothing to do with hardware and peripherals configuration.
My guess is that whenever the codec reaches the end of the buffer, it outputs an extra sample that produces this glitch.
Since i'm not very confident with all the peripheral configurations involved in the code, i ask you guys help.
If not resolving this mind twisting bug, at least help me isolate the problem to a specific driver configuration so that i can work on it by myself.
I'll copy the content of the Readme.md in the repository to give you some instructions on how the code is distributed across the project.
globals.h - contains the global declarations and definitions (such as the buffer size)
codec.h - is where the codec is initialized and all the relative peripherals are configured
processing.h - contains the function called by the DMA interrupt callback (located in codec.h), this produces just a simple sine wave.
main.cpp - well, as you can guess it's where all is initialized (main thread and DSP thread)
Thank you in advance for your time, i understand my question is not specific and immediate but i think the problem is strictly related to some bad configurations of mine, and this is really twisting my mind.
Hope I have given you all the necessary information, if not, please let me know and i'll provide more.
Thank you again.
/giorgio
It's been a few months now that i'm stuck on a noise coming out of the jack plug whenever the STM32 Discovery Board is powered on and connected (via the audio jack) to my audio interface, even if the board's output is not routed to the speakers.
This 6kHz noise is related to the audio buffer size, since i'm working with a sample rate of 48kHz and the buffer is 8 elements long, 48000 / 8 = 6000.
I also tried to double the buffer size and as expected the noise frequency fell down by half of its initial value.
I uploaded a reduced version of the source code.
I removed all the unnecessary code to avoid getting you guys lost in what has nothing to do with hardware and peripherals configuration.
My guess is that whenever the codec reaches the end of the buffer, it outputs an extra sample that produces this glitch.
Since i'm not very confident with all the peripheral configurations involved in the code, i ask you guys help.
If not resolving this mind twisting bug, at least help me isolate the problem to a specific driver configuration so that i can work on it by myself.
I'll copy the content of the Readme.md in the repository to give you some instructions on how the code is distributed across the project.
globals.h - contains the global declarations and definitions (such as the buffer size)
codec.h - is where the codec is initialized and all the relative peripherals are configured
processing.h - contains the function called by the DMA interrupt callback (located in codec.h), this produces just a simple sine wave.
main.cpp - well, as you can guess it's where all is initialized (main thread and DSP thread)
Thank you in advance for your time, i understand my question is not specific and immediate but i think the problem is strictly related to some bad configurations of mine, and this is really twisting my mind.
Hope I have given you all the necessary information, if not, please let me know and i'll provide more.
Thank you again.
/giorgio

