cancel
Showing results for 
Search instead for 
Did you mean: 

Wait but MCU is unblocked

XooM
Associate III

I haven't been able to wait 500ms without affecting the timers for 7 days.
In this block, doesn't PB14 become "0" after 500ms?
Even if I use comment lines, it doesn't work.

Note: volatile uint32_t Counter = 0;
The "Counter" variable is incremented every 1ms with Timer16.

 

** STM32F030C6T6 I'm using.

** Own PCB board..

*** Note: Card of a working system.. There is no card design error.

 

 

if(htim->Instance==TIM16)
		{
		 Counter++;

		if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13)==0)
		  {
			  if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_2)==0)
					 {
				         if(PA10_On==0)
				         {
                         HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_RESET);
                         HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14,GPIO_PIN_SET);
                         Counter=0;
                         PA10_On=1;

                         // Tick_PA10_On= HAL_GetTick();
                         // PA10_On=1;
				         }
				         else
				         {
				          if(Counter>500) // if((HAL_GetTick()-Tick_PA10_On)>=500)
							{
				        	 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14,GPIO_PIN_RESET);
				        	 Counter=501;
							}
				         }



				   	}
				else
					  {

					  	 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_SET);
					  }

		  }
		  else
		  {
			  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_RESET);

		  }
}

 

 

60 REPLIES 60
XooM
Associate III

I give energy to the circuit. I explain what I did in order.

1- I give PC13=0 (No output is active)
2- I give PA2=0, PB14 =1 becomes.. (it waits like that. It is not zero).
So it did not work, sorry.

XooM
Associate III

I added a project made with Stm32CubeIDE that only contains the following codes. Unfortunately, even this code doesn't work. I'm going to go crazy if I can't find where I made a mistake.

  while (1)
  {

	  if(a==0)
	  {
		TickTime=HAL_GetTick();
		a=1;
	  }

	  if(a==1 &&  (HAL_GetTick()-TickTime)>=500)
	  {
		  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
		  a=0;
	  }
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

The file is attached and only this code is written, there is no other code but it does not work. 

Know you how debug code ?

XooM
Associate III

I don't know

MM1_0-1731956005634.png

then switch to it.c and click on line set break point , on left click play button learn use debuger ...

MM1_1-1731956200888.pngMM1_2-1731956312732.png

 

XooM
Associate III

The program is starting to go crazy. This stm32 is going to drive me crazy. I made a mistake by giving up on MicroChip.

XooM
Associate III

HAL_delay command does not work either. Is there a solution for this?

Make sure that SysTick is causing HAL_GetTick() to advance.

If it is not, then HAL_Delay() will not work.

Make sure all the input and output lines are functional.

Need to start from first principles, and confirm what is and what isn't working.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I have written nothing but a simple blink program.HAL_Delay(500); is not working.I noticed that while I was suspecting that the GetTick(); function was not working.Then when I made a simple Toggle query, it turned out that HAL_Delay() was not working. I don't know how to solve this.

Seems you choice ST versions with some bugy frameworks. I understand your frustration , but try remove systick and use other timebase. Start with open ioc and free TIM16 disable it.

Then choice here

MM1_0-1731995149968.png

and test your HAL_Delay 500 toggle or my code.