
Otherwise, it turns off the LED by setting the GPIO pin 5 to the low state. If it is in the reset state or active low, it turns on an LED by setting the GPIO pin 5 of the GPIOA port to the high state.
#Stm32 nucleo board schematic code#
This code checks the state of the GPIO pin 13 of the GPIOC port. You will see in Device Configuration Tool, that now PC13 will be labeled accordingly.įirst, inside the main() function go to while(1) and insert the following lines of code. Here, give the label to the PC13 pin by giving it whatever name you want. Now select PC13 pin as a digital input pin by selecting option GPIO_INPUT as shown below:Īlso, go to System Core > GPIO > PC13 and the pin configuration for PC13 will open up. These configurations and parameters allow you to customize the behavior of the GPIO pins to suit the needs of your specific project and ensure proper functionality. You can assign a meaningful label, and later use the Find menu to locate and work with the GPIO pin based on its label. User Label: This is a customizable name assigned to a GPIO pin for easier identification and access.However, if your application requires a higher frequency, you can change this setting accordingly. GPIO Maximum output speed: The maximum output speed is initially set to Low for power consumption optimization.However, depending on your requirements, you can configure pull-up or pull-down options if supported by the specific pin. GPIO Pull-up/Pull-down: By default, no pull-up or pull-down resistors are enabled.GPIO mode: The mode automatically configures the pins with the appropriate alternate function and sets them to Output Push Pull mode, ensuring compatibility and stability.However, you can change it to High if needed. GPIO Output level: By default, the output level is set to Low, meaning the pin is at a low voltage.But you can also use an external push button in any one of the above configurations. #define GPIO_PULLDOWN 0x00000002U /*!< Pull-down activation */īut for the demonstration purpose, we will use the onboard push button of STM32 NUCLEO-F103RB. #define GPIO_PULLUP 0x00000001U /*!< Pull-up activation */ These values which can be passed to Pull members are: #define GPIO_NOPULL 0x00000000U /*!< No Pull-up or Pull-down activation */ This parameter can be a value of GPIO_Alternate_function_selection */ Uint32_t Alternate /*!< Peripheral to be connected to the selected pins. This parameter can be a value of GPIO_speed_define */ Uint32_t Speed /*!< Specifies the speed for the selected pins. This parameter can be a value of GPIO_pull_define */ Uint32_t Pull /*!< Specifies the Pull-up or Pull-Down activation for the selected pins. This parameter can be a value of GPIO_mode_define */ Uint32_t Mode /*!< Specifies the operating mode for the selected pins.

This parameter can be any value of GPIO_pins_define */ Uint32_t Pin /*!< Specifies the GPIO pins to be configured. In HAL libraries, these internal pull-ups and pull-down resistors can be configured through the GPIO_InitTypeDef struct by passing corresponding values to Pull member of the GPIO_InitTypeDef C struct. In STM32CubeIDE, we will configure it through a GUI tool. STM32 microcontroller’s GPIO ports also have internal pull-up and pull-down resistors which can be configured through the PUPDR register. Internal Pull-up and Pull-down Resistors STM32 Microcontrollers
