2024-11-19 04:27 AM
When I give the delay time greater than 300 for the code below (500ms or 1000ms), GetTick or HAL_Delay(500); functions do not work.
If I make the time 100ms, 200ms or 300ms, it works.
When I want to control the delay at longer times, the program does not work.
Where should I look for the problem?
I am using STM32F030C6T6.
if(PA10_On==0)
{
Tick_PA10_On = HAL_GetTick();
PA10_On=1;
}
if ( PA10_On==1 &&(HAL_GetTick() - Tick_PA10_On) >= 300)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
PA10_On=0;
}
For example, this code below does not work.
HAL_GPIO_WritePin(PA10_GPIO_Port,PA10_Pin,GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(PB14_GPIO_Port,PB14_Pin,GPIO_PIN_RESET);
HAL_Delay(500);
But this below code works.
HAL_GPIO_WritePin(PA10_GPIO_Port,PA10_Pin,GPIO_PIN_SET);
HAL_Delay(200);
HAL_GPIO_WritePin(PB14_GPIO_Port,PB14_Pin,GPIO_PIN_RESET);
HAL_Delay(200);
Waits of 300ms and below work.
Solved! Go to Solution.
2024-11-19 07:40 AM
@XooM wrote:
I don't use st board. I'm trying it on my own special pcb board.
That doesn't depend on the board. Except the fact that you are using an external Crystal, in that case we need to move the HSI as clock source.
2024-11-19 07:42 AM - edited 2024-11-19 07:42 AM
I do not use an external crystal.
2024-11-19 07:48 AM
That was not the question.
If you need an assistance you need to share your project to run it on a NUCLEO from our side.
2024-11-19 08:05 AM
@XooM wrote:I don't use st board. I'm trying it on my own special pcb board.
Again, I would strongly suggest that you don't do that!
That just adds unnecessary complications and unknowns - making it both harder for you, and harder for others to help you.
@XooM wrote:I don't know how to debug
That really is a basic skill that you need to start with.
Again, set aside your over-complicated, "special" board, and just concentrate on the basics on a well-known, standard board - a Nucleo board is ideal.
Basics for getting started:
You need to learn to walk before trying to run.
You need to lay foundations before putting fancy windows in.
2024-11-19 08:11 AM - edited 2024-11-19 08:13 AM
Show the declarations of all the variables used in your code, like Tick_PA10_On.
Show all the warnings you get while compiling the code. Correct your code to remove all the warnings.
Is the watchdog activated? If yes, then turn it off.