1. Basic introduction
1, ADC clock.
2, ADC channel.
The difference between the rule channel and the injection channel is still not fully understood, explained online
Regular channel:
Equivalent to a normal running program,
Inject channel:
It is equivalent to an "interruption", which interrupts the ongoing rule channel, so as to carry out the procedure of injecting the channel. After the injection channel completes the conversion, then continue to complete the conversion of the regular channel.
3. ADC trigger mode
It can be divided into software trigger and external trigger.
Software trigger means that the control register triggers an ADC conversion.
External trigger, the conversion can be triggered by external events (for example, timer capture, EXTI interrupt line), and the use of timer trigger is an external trigger.
trigger source
For the advanced timer tim1, tim8 has TRGO2 in addition to TRGO.
4. ADC conversion time
The minimum number of clocks required to take a sample.
Sampling time can be set.
5. ADC sampling frequency
Sampling frequency, such as using a timer trigger, the trigger frequency is the sampling frequency of the ADC, and the conversion time of the ADC limits the maximum sampling frequency.
6. ADC working mode
One-shot conversion mode , in single-conversion mode, the ADC performs one conversion.
Continuous conversion mode, in continuous conversion mode, ADC starts a new conversion immediately after finishing one conversion.
Two, stm32Cube IDE, software trigger single measurement setting
Three, program.
Initialization, in addition to the automatically generated initialization function, plus the function to turn on the ADC
HAL_ADC_Start(&hadc1);
test
uint32_t adc_value = HAL_ADC_GetValue(&hadc1);
Reference article:
(3 messages) [STM32] HAL library-ADC_Yiyi L's blog-CSDN blog_adc of hal library