Skip to main content
HBesi.1
Associate II
Mar 6, 2021 6:46 PM UTC
Solved

The signal Produced by DAC has errors

Hello,

I am building and electric field sensor. The driver signal for it is produced via DAC of the STM32F767zi microcontroller. The signal is 4 kHz and is generated at a sampling speed of 80 kHz via DMA and TIM6. As you can see from the picture the signal has errors in it like every 10-20 wavelengths there is 1 corrupted sample.

Best regards 0693W000008wDUqQAM.png

This topic has been closed for replies.
HBesi.1
HBesi.1Best answer
Associate II
Mar 7, 2021 9:04 PM UTC

The solution for the problem was changing the callback functions to:

void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)

{

//first half of adc is full

inbufPtr= &adc_val[0];

outbufPtr= &dac_val[0];

processDSP();

}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

{

inbufPtr= &adc_val[DATASIZE];

outbufPtr= &dac_val[DATASIZE];

processDSP();

}

cant really tell why this solved the problem. Occasionally it still happens that 1 sample is pulled high but it can be tolerated.

7 replies

Vangelis Fortounas
Associate II
Mar 6, 2021 11:05 PM UTC

Hello

seems like interruption from a higher priority interrupt routines causes DMA underruns.

waclawek.jan
Super User
Mar 7, 2021 7:31 AM UTC

But would underrun result in an unexpected value to be output? Wouldn't it produce a "stretch" rather than a "glitch"?

I don't think this can be solved without seeing substantial portion of the code.

JW

HBesi.1
HBesi.1Author
Associate II
Mar 7, 2021 8:52 AM UTC

The code is simple I load values of a cosine table into the DMA buffer. My first thought was that the DAC hit its limit regarding speed. 80kHz maybe too fast.

Piranha
Principal III
Mar 7, 2021 6:52 PM UTC

Is D-cache turned on? Is it managed properly?

waclawek.jan
Super User
Mar 7, 2021 6:57 PM UTC

Isn't the first or last value in the calculated array off? Read it out and check.

JW

HBesi.1
HBesi.1AuthorBest answer
Associate II
Mar 7, 2021 9:04 PM UTC

The solution for the problem was changing the callback functions to:

void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)

{

//first half of adc is full

inbufPtr= &adc_val[0];

outbufPtr= &dac_val[0];

processDSP();

}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

{

inbufPtr= &adc_val[DATASIZE];

outbufPtr= &dac_val[DATASIZE];

processDSP();

}

cant really tell why this solved the problem. Occasionally it still happens that 1 sample is pulled high but it can be tolerated.