The [STM32F051x6](https://www.ampheo.com/search/STM32F051) [microcontroller](https://www.ampheo.com/c/microcontrollers) features a 12-bit Successive Approximation Register (SAR) ADC.

Here are the key specifications and characteristics of this [ADC](https://www.onzuu.com/category/analog-to-digital-converters):
**ADC Core Specifications**
* Type: 12-bit Successive Approximation Register (SAR)
* Resolution: 12 bits (4096 possible values)
* Channels: Up to 16 external channels + 3 internal channels
* Conversion Speed: Up to 1 MSPS (Million Samples Per Second) at 14 MHz ADC clock
**Detailed Features**
**Input Channels:**
* 16 external analog inputs connected to GPIO pins
* 3 internal channels:
* Internal reference voltage (VREFINT)
* Internal temperature sensor
* VBAT monitoring (for battery applications)
**Conversion Modes:**
* Single conversion mode (one channel at a time)
* Continuous conversion mode (automatic repeated conversions)
* Scan mode (automatically converts a sequence of channels)
* Discontinuous mode
* Injected channels (for higher-priority conversions)
**Trigger Sources:**
* Software trigger
* Hardware triggers from timers (TIM1, TIM2, TIM3, TIM15)
* External triggers
**Data Management:**
* Data register: 12-bit right-aligned or 16-bit left-aligned
* Analog Watchdog - can monitor specific channels and generate interrupts when values go outside programmed thresholds
* DMA support for efficient data transfer without CPU intervention
**Typical Performance Characteristics**
* Supply voltage: 2.4V to 3.6V
* Analog supply voltage: 2.4V to 3.6V (VDDA)
* Input voltage range: 0V to VDDA
* Conversion time: As low as 1 μs in fast mode
* Sampling time: Programmable from 1.5 ADC cycles to 239.5 ADC cycles
**Example Configuration Code**
Here's a basic setup for the ADC in single conversion mode:
```
c
// Basic ADC initialization for STM32F051
void ADC_Init(void) {
// 1. Enable clock for ADC and GPIO
RCC->AHBENR |= RCC_AHBENR_GPIOAEN; // Enable GPIOA clock
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; // Enable ADC1 clock
// 2. Configure GPIO pin as analog input (e.g., PA0)
GPIOA->MODER |= GPIO_MODER_MODER0; // Analog mode for PA0 (11 in MODER0 bits)
// 3. Configure ADC
ADC1->CFGR1 = 0; // Default configuration
ADC1->CFGR2 = 0; // Default clock (PCLK/2)
ADC1->SMPR |= ADC_SMPR_SMP_0; // Sampling time selection
// 4. Calibrate ADC (mandatory after reset)
ADC1->CR |= ADC_CR_ADCAL; // Start calibration
while (ADC1->CR & ADC_CR_ADCAL); // Wait for calibration complete
// 5. Enable ADC
ADC1->CR |= ADC_CR_ADEN; // Enable ADC
while (!(ADC1->ISR & ADC_ISR_ADRDY)); // Wait until ADC ready
}
// Function to read ADC value from a channel
uint16_t ADC_Read(uint8_t channel) {
// Select channel
ADC1->CHSELR = (1 << channel);
// Start conversion
ADC1->CR |= ADC_CR_ADSTART;
// Wait for conversion complete
while (!(ADC1->ISR & ADC_ISR_EOC));
// Read result
return ADC1->DR;
}
```
**Key Advantages of SAR ADC in STM32F051**
1. Good balance of speed and accuracy - 1 MSPS is sufficient for many embedded applications
2. Low power consumption compared to other ADC architectures
3. Simple architecture - easy to understand and use
4. Flexible triggering allows synchronization with other system events
5. Internal channels enable monitoring of chip temperature and reference voltage
**Common Applications**
* [Sensor](https://www.ampheo.com/c/sensors) reading (temperature, pressure, light)
* Battery voltage monitoring
* [Potentiometer](https://www.onzuu.com/category/potentiometers)/[joystick](https://www.onzuu.com/category/joystick) position sensing
* Audio signal acquisition (lower frequency)
* Industrial control systems
The 12-bit SAR ADC in the [STM32F051x6](https://www.ampheoelec.de/search/STM32F051) provides a good compromise between performance, power consumption, and cost, making it suitable for a wide range of embedded applications requiring analog-to-digital conversion.