STM32F401: ADC Config,How I get a sampling freq ~100Hz) Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
raulvalencia
Posts: 6
Joined: Wed Jun 01, 2016 12:53 pm

STM32F401: ADC Config,How I get a sampling freq ~100Hz)

Post by raulvalencia »

Hi everyone,

I'm working with nucleo STM32F401 board and ChibiOS 16.1.3

My question is : how do I configure my ADCConversionGroup to have in channel 0 a sampling frequency = ~100 HZ, I read that we have to set the ADC_SMPR2 register but we have only 3 bits, I mean 8 choices...

Maybe if I use the Timer 3 TRGO event (or another one) to trigger my convert but the number of simples have to be 1?

I was reading that:

11.3.2 ADC clock
The ADC features two clock schemes:
• Clock for the analog circuitry: ADCCLK
This clock is generated from the APB2 clock divided by a programmable prescaler that
allows the ADC to work at fPCLK2/2, /4, /6 or /8. Refer to the datasheets for the
maximum value of ADCCLK.
• Clock for the digital interface (used for registers read/write access)
This clock is equal to the APB2 clock. The digital interface clock can be
enabled/disabled individually for each ADC through the RCC APB2 peripheral clock
enable register (RCC_APB2ENR).

somebody has any idea ?


Thank you in advance for your help,

Raul
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F401: ADC Config,How I get a sampling freq ~100Hz)

Post by Giovanni »

Hi,

If you need an accurate sampling rate then you need a GPT timer triggering the ADC via the TRGO signal, look at the GPT-ADC demos under /testhal, there is one for the F7 that can be used as reference for the F4.

Giovanni
raulvalencia
Posts: 6
Joined: Wed Jun 01, 2016 12:53 pm

Re: STM32F401: ADC Config,How I get a sampling freq ~100Hz)

Post by raulvalencia »

Thanks a lot,

I'm going to try that...



Raul
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: STM32F401: ADC Config,How I get a sampling freq ~100Hz)

Post by RoccoMarco »

Hi,
if you are using STM32 Nucleo-64 F401RE I have already ported that demo sometime ago. It should work with 16.1
http://www.playembedded.org/blog/wp-content/uploads/2016/04/RT-STM32F401RE-NUCLEO-GPT-ADC.zip

There are some other demos for that board here
http://www.playembedded.org/blog/en/download/

If you are using STM32F401C Discovery or a custom board you have to port it. Here some info about this procedure:
http://www.playembedded.org/blog/en/2016/05/29/how-to-port-a-chibios-demo/
Ciao,
RM
raulvalencia
Posts: 6
Joined: Wed Jun 01, 2016 12:53 pm

Re: STM32F401: ADC Config,How I get a sampling freq ~100Hz)

Post by raulvalencia »

Thanks!

your website is very interesting...

I'm going to see your demos...

Raul
Post Reply