Skip to main content
HBesi.1
Associate II
March 6, 2021
Solved

The signal Produced by DAC has errors

  • March 6, 2021
  • 5 replies
  • 2463 views

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.
Best answer by HBesi.1

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.

5 replies

Vangelis Fortounas
Associate II
March 6, 2021

Hello

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

waclawek.jan
Super User
March 7, 2021

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
March 7, 2021

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
March 7, 2021

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

waclawek.jan
Super User
March 7, 2021

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
March 7, 2021

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.