cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DSP noise with inbuilt ADC and DAC

A_Dave
Associate

I'm trying to perform signal filtering with STM32F407VGT. I've set up the ADC and DAC to work synchronously, triggered by a timer at 42kHz, and using DMA. The idea is to process half of the buffer while ADC is filling the other half. However, even without any processing, I'm getting a periodic noise in my signal(picture attached). Seems like some portion of the buffer is always messed up. Why is this happening and how can I fix it? I'm also attaching the relevant sections of my code here. Both ADC and DAC operate in 12bit mode and are triggered by Timer2. Both use DMA in circular mode.

0693W000000UQ7rQAG.jpg

#define DATASIZE 		64
#define FULLBUFFSIZE 		128
 
uint32_t adc_val[FULLBUFFSIZE];
uint32_t dac_val[FULLBUFFSIZE];
static volatile uint32_t* inbuffPtr;
static volatile uint32_t* outbuffPtr;
 
void process_DSP()
{
	for (int n=0; n<DATASIZE; n++)
	{
		outbuffPtr[n] = inbuffPtr[n];
	}
}
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
{
	inbuffPtr = &adc_val[0];
	outbuffPtr = &dac_val[DATASIZE];
	process_DSP();
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	inbuffPtr = &adc_val[DATASIZE];
	outbuffPtr = &dac_val[0];
	process_DSP();
}

1 ACCEPTED SOLUTION

Accepted Solutions

If the DMAs in both input and output buffer run in sync, then when processing first half of input buffer, DAC plays back from second half of output buffer, i.e. you want to place the result to first half of output buffer.

JW

View solution in original post

2 REPLIES 2

If the DMAs in both input and output buffer run in sync, then when processing first half of input buffer, DAC plays back from second half of output buffer, i.e. you want to place the result to first half of output buffer.

JW

You are spot on. Thank you so much!!