Stm32--gpio settings for pull-up and drop-down in input mode

Source: Internet
Author: User

The GPIO is in input mode, and the relevant configuration for the drop-down input and pull-up input is shown in the following figure. It is important to note that the drop-down input and the pull-up input are distinguished by the port output register GPIOX_ODR. As a result, when the pull-up/drop-down input is configured, the operation on the input to the GPIO is still configured for the register ODR associated with the output.


The above considerations appear when the actual code is written: (1) Library functions

Gpio_initstructure.gpio_pin  = gpio_pin_0;  PA0   
gpio_initstructure.gpio_mode = GPIO_MODE_IPD;//pa0 drop-down input  
gpio_init (Gpioa, &gpio_initstructure);
Gpio_resetbits (GPIOA,GPIO_PIN_0);		PA0 drop-off odr=0<strong>
</strong>

It is hereby stated that although the pull-up input mode Gpio_mode_ipu and the drop-down input mode GPIO_MODE_IPD are distinguished in Gpio_mode, the ODR registers are still required to be set when the Gpio initializes the configuration, as shown in the above Gpio_ Resetbits (gpioa,gpio_pin_0); operation.


(2) Register

gpioa->crl&=0xfffffff0;	PA0 set  
gpioa->crl|=0x00000008;	before purging PA0 input   
gpioa->odr|=0<<0;		PA0 drop-down <strong>
</strong>


In addition, the GPIO is in input mode and does not need to be set for MODE1 and MODE0 (default is 00 after initialization)


Output mode bit (configured in output mode only, not required in input mode)








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.