2020-12-09 12:38 AM
Hello everyone, i have a custom made board using a STM32L476RCT6, i am able to normally upload the bin files with the programmer etc, it's working properly, except for one thing, i can't use the HAL_drivers as the same way i use them with the Nucleo. For instance if i do
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,1);
HAL_Delay(1000);
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,0);
And run the MCU in debug mode, step by step, it will run just fine, but if i run it normally, it gets stuck on HIGH, never actually blinking.
But if i do:
HAL_GPIO_TogglePin(D1_GPIO_Port,D1_Pin);
HAL_Delay(1000);
It will work just fine. What is happening?
The code is generated by CubeMX, i will post a github link below:
https://github.com/Rozakos/STM32/blob/master/HELP
Any help is appreciated!
2020-12-09 05:06 AM
You need a delay after you reset the pin if you want to be able to see it blink.
while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,1);
HAL_Delay(1000);
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,0);
/* USER CODE BEGIN 3 */
}
Something like this:
while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,1);
HAL_Delay(1000);
HAL_GPIO_WritePin(D1_GPIO_Port,D1_Pin,0);
HAL_Delay(1000); // <--------
/* USER CODE BEGIN 3 */
}
Also note that your code is not within USER CODE begin/end comments so it will be erased on regeneration.