Question
Trying to learn the STcube/HAL-interfaces on a NUCLEO-F446RE but got stuck at a very basic level. To control a pin (LED) worked well but trying to read the button-pin (PC13) doesn't seem to work. Though an example with interrupt on that pin work. See
HAL_Init();
SystemClock_Config();// Configure the system clock to 180 MHz
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); // PC13 input (?)
while(1)
{
printf("Button= %d\n", (int)HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) );// Always prints 0
HAL_Delay(500);
}