Hi @Zaidii1122 ,
As you are a beginner and if you don't want to use a timer but just GPIOs, you can simply toggle the pin you want at 20ms (1/50Hz) using: HAL_Delay(20). But this in not the way we recommend a such usage.
This is an example jhow to toggle the pin 5 on GPIOA:
/* -1- Enable GPIOA Clock (to be able to program the configuration registers) */
__HAL_RCC_GPIOA_CLK_ENABLE();
/* -2- Configure PA05 IO in output push-pull mode to
drive external LED */
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* -3- Toggle PA05 IO in an infinite loop */
while (1)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
/* Insert delay 20 ms */
HAL_Delay(20);
}
}
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.