while loop requires semicolon or not
When I run the below code snippet, it just runs for once, however when I added semicolon as in latter code piece, it runs as expected, continously.
Could you please tell me why is the difference?
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
while(!(TIM6->SR & TIM_SR_UIF))
TIM6->SR = 0;
HAL_GPIO_TogglePin(GPIOD, green_Pin);
*************************THE SECOND CODE PIECE IS BELOW**************************************
}
/* USER CODE END 3 */
}
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
while(!(TIM6->SR & TIM_SR_UIF));
TIM6->SR = 0;
HAL_GPIO_TogglePin(GPIOD, green_Pin);
}
/* USER CODE END 3 */
}