cancel
Showing results for 
Search instead for 
Did you mean: 

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

JFlowers
Associate II

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!

2 REPLIES 2
TDK
Guru

Initialize the clock.

Initialize the pin as an output using HAL_GPIO_Init

Set the pin high or low using HAL_GPIO_WritePin.

If you feel a post has answered your question, please click "Accept as Solution".
JFlowers
Associate II

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);