2020-10-08 05:54 AM
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);
}
2020-10-08 07:12 AM
> __HAL_RCC_GPIOA_CLK_ENABLE();
> HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) );
Enable the GPIOC clock instead of GPIOA.
2020-10-09 01:16 AM
Great thanks, now it works!!!!
Regards Ricard