2019-01-30 10:40 PM
I wish to know how Can I set a pin as analog input for ADC.
Bits 31:0MODE[15:0][1:0]: Port x configuration I/O pin y (y = 15 to 0)
These bits are written by software to configure the I/O mode.
00: Input mode
01: General purpose output mode
10: Alternate function mode
11: Analog mode (reset state)GPIO_MODER_MODE14_? | GPIO_MODER_MODE15_?;
2019-01-30 11:19 PM
If, for example, you want to set PB12 as analog, you can write
GPIOB->MODER |= (3 << (2 * 12));
or
GPIOB->MODER |= (3 << GPIO_MODER_MODE12_Pos);
Note, that it's the reset state in many STM32 families, mainly the STM32Lxx (as is given also in the snippet of documetnation you posted above).
JW
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.