2018-08-15 12:38 AM
I use the BSP functions to record audio. The sampling frequency is set to 8000 Hz and the buffer size to save the recorded data into is set at 8000 elements long.
It would make sense if the time to fill up the buffer is 1s. However it takes exactly 500ms.
I cannot figure out why this is the case. I use one channel for recording and the DMA is set to take in half-words.
Any ideas as to why this is the case?
2018-08-15 01:32 AM
You did provide almost no relevant information (sampling frequency of what, what's the source of that frequency, what's the sampling mechanism) so a couple of wild guesses:
Your system clock frequency may be different from what you think it is (verify by outputting it onto a MCO pin); or you are using a timer as the source of sampling and assume its input clock is equal to the APB clock, while APB has been divided in RCC thus timer has twice as high input frequency (verify by outputting a PWM waveform from the timer); you are using DMA and have active both the half-buffer and transfer-completed interrupts (verify by reading back the DMA registers content and check).
JW
2018-08-15 02:20 AM
Apologies , let me be more specific.
I am using the BSP drivers to communicate with the WM8994 chip on the board. I am wanting to record audio.
I initialise the WM8994 chip be calling-
BSP_AUDIO_IN_Init(AUDIO_FREQUENCY_8K , 16 ,1) - where 16 refers to bit resolution and 1 refers to the number of channels.
I then start the recording process by calling -
BSP_AUDIO_IN_Record(recording_buffer , 8000) ;
The BSP Audio use the SAI peripheral to communicate the WM8994. I have also set this sampling frequency to 8000 Hz.
The 8000 element long buffer is taken 0.5s to go into the DMA transfer complete callback. This is where the issue lies. It should be taking 1s.
2018-08-15 08:04 AM
Observe the I2S clocks, using oscilloscope/logic analyzer. Are they at the frequency you expect?
JW