GetTick() and HAL_Delay(xxx);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 4: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.
- Labels:
-
STM32F0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 8:11 AM - edited ‎2024-11-19 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 4: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"?
- Don't give any delay at all?
- Give an excessive delay?
- Crash?
- Other??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 4: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 4: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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 6:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 6: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 ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 6:59 AM
The relationship between the two is written in the title. Neither of them works for 500 ms delay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 7:05 AM
Not sufficient as information .. may be you need to share your project to reproduce it on a NUCLEO board (NUCLEO-F030R8).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-19 7: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
