cancel
Showing results for 
Search instead for 
Did you mean: 

Need very slow ADC readings on STM32G474

ValterMatos
Senior

I'm using the STM32G474 at 170MHz.

Is it possible to simulate hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV512; since the G474  only recognizes up to ADC_CLOCK_ASYNC_DIV256;

I need very slow readings from the ADC.

Thank you

Valter

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

> Oversampling didn't work correctly.

Then you didn't do it right.

x = (x0 + x1) / 2

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
TDK
Super User

Sure, slow down the ADC clock or use software oversampling. Note that there is a minimum FADC requirement of 140 kHz that you need to be at/above. You can use software oversampling to achieve lower effective values.

 

If you feel a post has answered your question, please click "Accept as Solution".
mƎALLEm
ST Employee

Hello,

Use a timer to trigger the ADC readings.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Not yet. I've tried several programming alternatives and still haven't been able to solve it. Oversampling didn't work correctly.
I'll try a timer to trigger the ADC readings.
I need to simulate a 512 pressscaler on the ADC readings because the G474 only accepts up to 256.
I wouldn't like to reduce the clock speed.

TDK
Super User

> Oversampling didn't work correctly.

Then you didn't do it right.

x = (x0 + x1) / 2

If you feel a post has answered your question, please click "Accept as Solution".

G474 has an option to choose clock for ADC, 

  RCC_PeriphCLKInitTypeDef PeriphClkInit  = {0};

  PeriphClkInit.PeriphClockSelection      = RCC_PERIPHCLK_ADC12;
  //PeriphClkInit.Adc12ClockSelection       = RCC_ADC12CLKSOURCE_SYSCLK;
  PeriphClkInit.Adc12ClockSelection       = RCC_ADC12CLKSOURCE_PLL;

 Using PLL instead of SYSCLK allows to generate any clock, simply changing M and N PLL's settings.

I tested this mode not for lower, but higher speed, overdriving ADC up to 168 MHz. And it works.

Very good.

I'll review the code.
Thank you for the suggestion.