cancel
Showing results for 
Search instead for 
Did you mean: 

DAC Noise pulse on STM32L475

PeterJ
Associate II

Posted on October 16, 2017 at 17:08

I am experiencing problems with my code, I was trying to change the code to get much faster ADC + Calculations + DAC speed.

Basically I want to start the 2 ADCs and when the fast ADC in done I want to output the ADC value on the DAC (after some light calculations).

The ADC does 32 samples (HW oversampling) in aproximately 43us and outputs the corresponding value on the DAC1-2 every time the conversion is completed so it should not be even close to the maximum the mcu should be able to do I believe?

I am fairly new to MCU programming but have done some other coding in C and Delphi (some years ago) so not completely new to coding. 

I am using IAR workbench newest version (code size limited free version).

The code is running the following:

ADC1, 6 channels running DMA using TIM2 as trigger, this is not running HW oversampling but I will change it later so it does run 8,16 or 32x HW oversampling to get the average calculated automatically.

ADC3 high speed on one channel, continues mode and I poll for EOC.

DAC1-1, output a 15kHz 24point sine.

DAC1-2, must output the corrected ADC3 values, currently it just outputs a constant value every 43us but sometimes it 'Miss' a value and outputs another value for 43us,it appears to be the same value every time.

The code is not nearly ready and much has been removed to clarify what causes it to fail, I discovered that it seems to be caused by the DMA access for ADC1 and DAC1-1, when I disable either of the 2 lines of code, the DAC1-2 output is steady without 'noise'.

HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*)sine_wave_array_24, 24, DAC_ALIGN_12B_R);//Sinus generator

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADC1ConvertedValues, 48);

If I disable the following line, the duration of the 'noise' pulse is reduced to approximately 2us:

HAL_ADC_PollForConversion(&hadc3, 10);

I have attached the main.c file.

A

ny help is appreciated.

Peter

0 REPLIES 0