Config ADC via HAL to lower Sample Time

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
dacoon
Posts: 1
Joined: Mon Mar 07, 2022 8:33 am

Config ADC via HAL to lower Sample Time

Post 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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Config ADC via HAL to lower Sample Time

Post 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
elijahnelson
Posts: 1
Joined: Tue Sep 12, 2023 8:00 am

Re: Config ADC via HAL to lower Sample Time

Post by elijahnelson »

I want to sample my EEG Data at 1kHz, is my conversion time 1ms?how can I arrange sampling time?
Post Reply

Return to “General discussion”