cancel
Showing results for 
Search instead for 
Did you mean: 

GetTick() and HAL_Delay(xxx);

XooM
Associate III

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.

14 REPLIES 14

@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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
XooM
Associate III

I do not use an external crystal.

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@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:

https://community.st.com/t5/stm32-mcus-products/for-better-learning-stm32-programming-and-debugging/m-p/719485/highlight/true#M260696

You need to learn to walk before trying to run.

You need to lay foundations before putting fancy windows in.

gbm
Lead III

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.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice