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.
2024-11-19 04:32 AM
@XooM wrote: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.
What do you mean by, "do not work"?
2024-11-19 04:37 AM
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);
If I write the code above, the PA10 pin goes HIGH and LOW at 200ms intervals.
but the duration is a larger value like 400ms 500ms. It remains in the HIGH position.
2024-11-19 04:54 AM
Still not clear what is actually happening.
Are you saying that, with a delay value over ~ 400, your code just "stops" at the HAL_Delay() call?
ie, your code becomes equivalent to:
HAL_GPIO_WritePin(PA10_GPIO_Port,PA10_Pin,GPIO_PIN_SET);
while(1); // Code "sticks" here ?
2024-11-19 06:31 AM
When I give a value higher than 300ms for the wait time, the output remains in the HIGH position.
I don't know what to do to understand clearly.
I don't know that much.
but I can't control anything with a 500ms delay.
HAL_delay or Gettick both don't work.
2024-11-19 06:37 AM
2024-11-19 06:39 AM
What is the relation between:
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;
}
and:
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);
?
Need to be concise ..
2024-11-19 06:59 AM
The relationship between the two is written in the title. Neither of them works for 500 ms delay.
2024-11-19 07:05 AM
Not sufficient as information .. may be you need to share your project to reproduce it on a NUCLEO board (NUCLEO-F030R8).
2024-11-19 07:11 AM
I don't use st board. I'm trying it on my own special pcb board. Can I have a chance to debug? rx tx is not connected. I'm connected with swdio swclk gnd vcc. I don't know how to debug