2022-02-11 10:18 AM
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!
2022-02-11 10:44 AM
Initialize the clock.
Initialize the pin as an output using HAL_GPIO_Init
Set the pin high or low using HAL_GPIO_WritePin.
2022-02-11 11:05 AM
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);