Page 1 of 1

Config ADC via HAL to lower Sample Time

Posted: Tue Mar 08, 2022 9:59 am
by dacoon
Hi,

I try now for nearly 1 week to understand how to define in arduino IDE the HAL to define the sample time for the ADC.

For a science experiment, I need to log some sample in 10ms. I was first try to use the arduino Nano. Working fine and I could also get high number of samples when changing the prescaler. But the Nano has some limitation like 10 instead of 12Bit and the more important, only 2kbyte sram. So I was thinking to store more sample in the timeframe with the STM32 (blue pill). But analogRead() is in the default configuration to slow. Was then checking the o-scope project, but this is not building in the arduino IDE with the offical core. Was then checking the other cores, but also every time was getting other build issues.

If I try to set the register, they keep empty.

Code: Select all

ADC_SMPR1(ADC_SAMPLETIME_1CYCLE_5,ADC_CHANNEL_0);
Was also try to test the WatchDog Sample: viewtopic.php?f=41&t=110

But also here the build is failing. Complain that "HAL_ADC_MspInit" is multiple times defined.

So I'm confused and can't find any good documentation about this topic. So can someone help here?

Thanks.

Re: Config ADC via HAL to lower Sample Time

Posted: Tue Mar 08, 2022 10:16 am
by fpiSTM
As stated in the watchdog example, the main trick is to disable HAL ADC usage by the Arduino API by defining -DHAL_ADC_MODULE_ONLY in build_opt.h file.

https://github.com/stm32duino/wiki/wiki ... uild_opt.h
https://github.com/stm32duino/wiki/wiki ... figuration

Re: Config ADC via HAL to lower Sample Time

Posted: Tue Sep 12, 2023 8:07 am
by elijahnelson
I want to sample my EEG Data at 1kHz, is my conversion time 1ms?how can I arrange sampling time?