Page 1 of 1
ADC sampling time setting.
Posted: Fri Jun 03, 2022 4:27 pm
by hermit
Hi, I'm using an ADC1 IN0 on an STM32F103C8xx to measure temperature with an NTC100K thermistor. My code works fine but I have a question about the sample rate. So according to the STM32 reference manual I've calculated that when I set the Sampling Time in CubeIDE to 239,5 (maximum) the ADC will return a measurement every 21us - (239,5 + 12,5)/12. Is there a way to configure the ADC to get a measurement every cca 15ms?
Re: ADC sampling time setting.
Posted: Fri Jun 03, 2022 6:26 pm
by ag123
you can use a hardware timer.
https://github.com/stm32duino/wiki/wiki ... er-library
Code: Select all
HardwareTimer timer(TIM1);
void readAdc() {
uint16_t value = analogRead(pin);
...
}
void setup() {
timer.pause();
timer.setoverflow(15000,, MICROSEC_FORMAT);
timer.refresh();
timer.attachInterrupt(readAdc);
timer.resume();
}
void loop() {
}
Re: ADC sampling time setting.
Posted: Sat Jun 04, 2022 9:39 pm
by hermit
That works. Thank you for your assistance.