cancel
Showing results for 
Search instead for 
Did you mean: 

Connection between ADC Clock and sample rate

DeBa92
Associate II

Hello all,
I am a beginner in the world of STM32 programming and need a little help with the ADCs.
I am currently using the STM32H735IG Discovery Kit and CubeIDE.

For an ongoing project I am using the ADC1 to sample channel IN0.
The DMA and sampling is working fine, but i am not sure how to set up the clockrate of the ADC properly.
The ADC is currently running in Asynchronous mode with divider 1 and the sampling time is set to 64,5 Cycles.

DeBa92_2-1692797787658.png

The clock rate of the ADC is currently set to 2.34375 MHz in the Clock Configuration.
DeBa92_0-1692797213957.png
Currently i store 16 samples in my DMA buffer:

 

HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADC_DMA_buffer, 16);

 

To monitor if the the ADC is working fine I am toggling an LED on the discovery board and monitor the signal with an Oscilloscope.

 

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_3);
}

 

With the current settings I can measure a frequency of 17,36 kHz on my LED.
This value times 16 samples times 2 toggles for one pulse, should be the actual sample rate of the ADC.

Now to the problem:
When I increase the clock frequency of the AD converter, to lets say 50 Mhz, the sample rate does not change
and I don't know why. The LED has still the same frequency of 17,36 kHz. Is there something I am missing?
In my imagination I thought the clock frequency should directly relate to the sampling rate of the ADC.

DeBa92_1-1692797726816.png

I hope someone can help me with this problem.
Thanks and best regards,

Dennis

 

10 REPLIES 10

Even with the Timer triggering the ADC, the ADC Clock frequency has no visible influence and I don't know why.
Currently I am generating a 500 kHz PWM signal from a Timer to trigger my ADC.

- You can use timer16 instead of your pwm and use internal trigger, the event out to as external trigger for adc
and your ADC are going to start sampling every trigger event without physical connect.
if you don't use multiplexing on ADC, the scan mode is not necessary.
you should disable a adc continuous mode and enable DMA continuous request.
and So you can check every adc conversation complete by callback function : HAL_ADC_ConvCpltCallback

for the 20KHz noise that it's possible from your switching regulator or some invertor in your system.