Skip to main content
Graduate II
February 11, 2022
Question

How to set a GPIO pin on CN1 like D8 of B-L475E-IOT01A ?

  • February 11, 2022
  • 2 replies
  • 948 views

How do I set/reset a GPIO pin on CN1 like D8 (PB2, pin 37 of STM32L475VGT6) of B-L475E-IOT01A ?

This is NOT working:

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);

Also, is there a code line or two to set as pull-up or pull-down output and initially set at 0 volts by default?

Help, please.

Thank you!

    This topic has been closed for replies.

    2 replies

    Super User
    February 11, 2022

    Initialize the clock.

    Initialize the pin as an output using HAL_GPIO_Init

    Set the pin high or low using HAL_GPIO_WritePin.

    JFlowersAuthor
    Graduate II
    February 11, 2022

    Thanks, TDK!

    For the record, this worked:

    __HAL_RCC_GPIOB_CLK_ENABLE();  

      

    GPIO_InitTypeDef GPIO_InitStructure = {0};

      

    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;

    GPIO_InitStructure.Pull = GPIO_NOPULL;

    GPIO_InitStructure.Pin = GPIO_PIN_2; /*PB2, D8 on CN1 */

    HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

    HAL_GPIO_WritePin(GPIOB, GPIO_PIN_2, GPIO_PIN_SET);