Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| stm32:peripherals:adc [2016/03/02 10:51] – feur | stm32:peripherals:adc [2022/12/28 08:11] (current) – ruan | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| The ADC of the STM32F429ZI has a 12 bit resolution and up to 19 multiplexed channels. \\ | The ADC of the STM32F429ZI has a 12 bit resolution and up to 19 multiplexed channels. \\ | ||
| - | A analog watchdog | + | An analog watchdog |
| \\ {{adc_complete.svg}} \\ \\ | \\ {{adc_complete.svg}} \\ \\ | ||
| Line 15: | Line 15: | ||
| * DMA and Interrupt support. | * DMA and Interrupt support. | ||
| \\ | \\ | ||
| + | ===== Configuration Registers ===== | ||
| - | ===== Programming Example ===== | + | ==== ADC_CCR - Common control register |
| - | <code c> | + | \\ {{adc_reg_ccr.svg}} \\ \\ |
| - | #include " | + | |
| - | RCC-> | + | |< 100% 5em 5em >| |
| - | RCC->APB2ENR | + | |ADCPRE|00|ADCCLK |
| - | + | |:::|01|ADCCLK => f<sub>PCLK2</sub> / 4| | |
| - | /* Configure GPIO pin F.6 in analog input mode. */ | + | |::: |
| - | GPIOA-> | + | |::: |
| - | + | ||
| - | /* No ADC common configuration, | + | |
| - | + | ||
| - | /* Configure ADC3 channel | + | |
| - | ADC3-> | + | |
| - | 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-> | + | |
| - | + | ||
| - | /* Start conversion */ | + | |
| - | uint32_t data; | + | |
| - | ADC3->CR2 |= (0x1 << 30u); /* Start conversion. */ | + | |
| - | while (!(ADC3->SR & (0x1 << 1u))); | + | |
| - | data = ADC3->DR; | + | |
| - | </code> | + | |
| - | + | ||
| - | ===== Configuration Registers ===== | + | |
| - | + | ||
| - | ==== CRx ==== | + | |
| - | + | ||
| - | === CR1 === | + | |
| - | Configuration register 1 | + | ==== ADCx_CR1 - Configuration register 1 ==== |
| \\ {{adc_reg_cr1.svg}} \\ \\ | \\ {{adc_reg_cr1.svg}} \\ \\ | ||
| |< 100% 5em 5em >| | |< 100% 5em 5em >| | ||
| - | |SCAN|0|Scan mode diabled | + | |SCAN|0|Scan mode disabled |
| |:::|1|Scan mode enabled| | |:::|1|Scan mode enabled| | ||
| |RES|00|12 bit, 15 ADCCLK cycles conversion time (reset state)| | |RES|00|12 bit, 15 ADCCLK cycles conversion time (reset state)| | ||
| Line 60: | Line 39: | ||
| |:::|11|6 bit, 9 ADCCLK cycles conversion time| | |:::|11|6 bit, 9 ADCCLK cycles conversion time| | ||
| - | === CR2 === | + | ==== ADCx_CR2 - Configuration register 2 ==== |
| - | + | ||
| - | Configuration register 2 | + | |
| \\ {{adc_reg_cr2.svg}} \\ \\ | \\ {{adc_reg_cr2.svg}} \\ \\ | ||
| Line 88: | Line 65: | ||
| |::: | |::: | ||
| - | ==== SMPRx ==== | + | ==== ADCx_SMPR1 - Sample time register 1 ==== |
| - | + | ||
| - | === SMPR1 === | + | |
| - | + | ||
| - | Sample time register 1 | + | |
| \\ {{adc_reg_smpr1.svg}} \\ \\ | \\ {{adc_reg_smpr1.svg}} \\ \\ | ||
| - | === SMPR2 === | + | ==== ADCx_SMPR2 - Sample time register 2 ==== |
| - | + | ||
| - | Sample time register 2 | + | |
| \\ {{adc_reg_smpr2.svg}} \\ \\ | \\ {{adc_reg_smpr2.svg}} \\ \\ | ||
| Line 110: | Line 81: | ||
| |:::|011|56 cycles sampling time|111|480 cycles sampling time| | |:::|011|56 cycles sampling time|111|480 cycles sampling time| | ||
| - | ==== SQRx ==== | + | ==== ADCx_SQR1 - Sequence register 1 ==== |
| - | + | ||
| - | === SQR1 === | + | |
| - | + | ||
| - | Sequence register 1 | + | |
| \\ {{adc_reg_sqr1.svg}} \\ \\ | \\ {{adc_reg_sqr1.svg}} \\ \\ | ||
| - | === SQR2 === | + | ==== ADCx_SQR2 - Sequence register 2 ==== |
| - | + | ||
| - | Sequence register 2 | + | |
| \\ {{adc_reg_sqr2.svg}} \\ \\ | \\ {{adc_reg_sqr2.svg}} \\ \\ | ||
| - | === SQR3 === | + | ==== ADCx_SQR3 - Sequence register 3 ==== |
| - | + | ||
| - | Sequence register 3 | + | |
| \\ {{adc_reg_sqr3.svg}} \\ \\ | \\ {{adc_reg_sqr3.svg}} \\ \\ | ||
| Line 141: | Line 104: | ||
| ===== Status Register ===== | ===== Status Register ===== | ||
| - | ==== SR ==== | + | ==== ADCx_SR - Status register |
| - | + | ||
| - | Status register | + | |
| \\ {{adc_reg_sr.svg}} \\ \\ | \\ {{adc_reg_sr.svg}} \\ \\ | ||
| Line 151: | Line 112: | ||
| ===== Data Register ===== | ===== Data Register ===== | ||
| - | ==== DR ==== | + | ==== ADCx_DR - Data register |
| - | + | ||
| - | Data register | + | |
| \\ {{adc_reg_dr.svg}} \\ \\ | \\ {{adc_reg_dr.svg}} \\ \\ | ||
| Line 159: | Line 118: | ||
| * Register is read only \\ \\ | * Register is read only \\ \\ | ||
| - | ===== Legend | + | ===== Programming Example |
| + | |||
| + | <code c> | ||
| + | #include " | ||
| + | |||
| + | RCC-> | ||
| + | RCC-> | ||
| + | |||
| + | /* Configure GPIO pin F.6 in analog input mode. */ | ||
| + | GPIOA-> | ||
| - | \\ {{legende.svg}} \\ \\ | + | /* No ADC common configuration, |
| + | /* Configure ADC3 channel 4. */ | ||
| + | ADC3-> | ||
| + | ADC3-> | ||
| + | ADC3-> | ||
| + | ADC3-> | ||
| + | |||
| + | /* Start conversion */ | ||
| + | uint32_t data; | ||
| + | ADC3-> | ||
| + | while (!(ADC3-> | ||
| + | data = ADC3-> | ||
| + | </ | ||
| + | \\ | ||