Electrical Engineering Asked by Ananthakrishnan on November 16, 2021
sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES_5;
This is an expression from ADC init function for stm32f1xx. I would like to know what this expression really does.I used cubeMX to generate code. Also kindly define the difference between sampling time,sampling rate and sampling frequency in ADC.Thanks.
#define ADC_SMPR_SMPR_1 ADC_SMPR_SMP_1
#define ADC_SMPR_SMP_1 ((uint32_t)0x00000002)
#define ADC_SMPR_SMPR_0 ADC_SMPR_SMP_0
#define ADC_SMPR_SMP_0 ((uint32_t)0x00000001)
#define ADC_SAMPLETIME_28CYCLES_5 ((uint32_t)(ADC_SMPR_SMPR_1 | ADC_SMPR_SMPR_0))
hadc->Instance->SMPRx |= ADC_SMPR1(sConfig->SamplingTime, sConfig->Channel);
where hadc is the handler for ADC, and the x in the end of SMPR is 1, 2 or 3 (as you can see there are 3 SMPR registers ... in the case of STM32F10x there are only 2, meaning less channels).
If you take a look at the reference manual you will see this:
If you take a closer look you will see that 3 bits define the sample time .. and the entire register is separated every 3 bits for each channel ... since you have more channels than only one 32 bit register can display, there are more registers to define the sampling rate for each channel.
This question shows that you haven't done any research or you don't even know where to begin looking. I suggest you take a little bit more time reading the reference manual (may be differente for every family) and datasheet ... not more than 100 pages maximum for the ADC.
Answered by morcillo on November 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP