Analog Digital Converter

The ADC of the STM32F429ZI has a 12 bit resolution and up to 19 multiplexed channels.
An analog watchdog monitors the input voltage and can take action if necessary.




  • Configurable 12-, 10-, 8- or 6 bit resolution.
  • Single and continuous conversion modes.
  • Programmable conversion time per channel.
  • External trigger options.
  • Dual / Triple mode with 2 or more ADCs.
  • DMA and Interrupt support.





ADCPRE00ADCCLK ⇒ fPCLK2 / 2 (reset state)
01ADCCLK ⇒ fPCLK2 / 4
10ADCCLK ⇒ fPCLK2 / 6
11ADCCLK ⇒ fPCLK2 / 8




SCAN0Scan mode disabled (reset state)
1Scan mode enabled
RES0012 bit, 15 ADCCLK cycles conversion time (reset state)
0110 bit, 13 ADCCLK cycles conversion time
108 bit, 11 ADCCLK cycles conversion time
116 bit, 9 ADCCLK cycles conversion time




ADON0Disable analog digital converter (reset state)
1Enable analog digital converter
CONT0Single conversion mode (reset state)
1Continuous conversion mode
DMA0DMA mode disabled (reset state)
1DMA mode enabled
ALIGN0Data aligned to the right side (bit 0) (reset state)
1Data aligned to the left side (bit 15)
EXTSEL0000TIM1 CC1 event (reset state)1000TIM3 TRGO event
0001TIM1 CC2 event1001TIM4 CC4 event
0010TIM1 CC3 event1010TIM5 CC1 event
0011TIM2 CC2 event1011TIM5 CC2 event
0100TIM2 CC3 event1100TIM5 CC3 event
0101TIM2 CC4 event1101TIM8 CC1 event
0110TIM2 TRGO event1110TIM8 TRGO event
0111TIM3 CC1 event1111EXTI line 11 event
EXTEN00Trigger disabled (reset state)10Trigger on falling edge
01Trigger on rising edge11Trigger on both edges
SWSTART0No conversion (reset state)
1Start conversion of regular channels







Description

SMPx0003 cycles sampling time (reset state)10084 cycles sampling time
00115 cycles sampling time101112 cycles sampling time
01028 cycles sampling time110144 cycles sampling time
01156 cycles sampling time111480 cycles sampling time










Description

L*xxxxLength of sequence list → nr. of conversions
SQy**xxxxxChannel nr. of #y conversion

* Number of Last SQy register used in conversion.
** SQ2 ← Channel in this register gets converted after channel in register SQ1.




Status bits are set by hardware and cleared by software (only possible to write 0).




* Register is read only

#include "reg_stm32f4xx.h"
 
RCC->AHBENR[0] |= (0x1 <<  5u);         /* Enable GPIOF clock. */
RCC->APBENR[1] |= (0x1 << 10u);         /* Enable ADC3 clock. */
 
/* Configure GPIO pin F.6 in analog input mode. */
GPIOA->MODER |= ~(0x3 << 6u);         /* Set pin 6 to analog input mode. */
 
/* No ADC common configuration, ADCCLK => PCLK2 / 2 => 42 MHz. */
 
/* Configure ADC3 channel 4. */
ADC3->CR1 |= (0x3 << 24u);            /* Set resolution to 6 bit. */
ADC3->SQR3 |= (4u << 0u);             /* Channel 4 first in conversion sequence (SQ1). */
ADC3->SQR1 |= (0x0 << 20u);           /* Set L to 0 -> only 1 channel (SQ1) in sequence. */
ADC3->CR2 |= (0x1 << 0u);             /* Enable ADC3. */
 
/* Start conversion */
uint32_t data;
ADC3->CR2 |= (0x1 << 30u);            /* Start conversion. */
while (!(ADC3->SR & (0x1 << 1u)));    /* Wait for EOC flag (end of conversion). */
data = ADC3->DR;


  • stm32/peripherals/adc.txt
  • Last modified: 2022/12/28 08:11
  • by ruan