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

so why isn't Hal_delay working?
My problem is exactly that the hal_delay function isn't working.


Because you are not calling Hal_delay() anywhere in your code.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

@XooM wrote:

timer16 and SerialWire what do you want me to do


Ahh boy select as on my image  Chekbox on serial wire when you used debuger this is good point and select TIM16 as your application timebase , MX then for you after generate code changes delay control from systick to TIM16 and setup 1ms. No more is required. Test toggle with this

:)

XooM
Associate III

can you set it up and send it to me.
I'm so confused..

	  HAL_GPIO_WritePin(PA10_GPIO_Port,PA10_Pin,GPIO_PIN_SET);
	  HAL_Delay(1000);
	  HAL_GPIO_WritePin(PA10_GPIO_Port,PA10_Pin,GPIO_PIN_RESET);
	  HAL_Delay(1000);

 

Amusing active high LED. What do you observe?

  • Pin is set high and LED turns on? If not then it doesn't reach the first statement and the issue is not HAL_Delay()
  • Pin set high but never turned low? Then HAL_Delay takes infinite amount of time or very long. Try using a smaller delay in case it is very slow. If it still doesn't turn off, then HAL_Delay is indeed an issue.
  • LED blinks so fast it appears dimmed, Then HAL_Delay takes too short an amount of time.
Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

PA10 BECOMES 1 BUT DOES NOT BECOME 0 AFTER 1 SECOND.

what is the value of the return code of HAL_InitTick()?
Have you tried the other startup file (.bak)? The modification may be incorrect. If interrupt vector table not correct interrupts can fire and call the wrong code.
Do you use some kind of bootloader? Did the original application use a different linker file? It seems you are using the default linker file.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

I see you accepted a solution out of nowhere, but you didn't write a final post. I'd like to know what happened. Were you able to get systick working? Or did you get timer16 working?
If so why didn't systick work?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

I apologize for not explaining. I'll explain it right away.

MCU was constantly resetting because WDT was unchecked = hw enabled in the options byte settings. It was due to my rookie mistake.


@XooM wrote:

MCU was constantly resetting because WDT was disabled in the options byte settings. It was due to my rookie mistake.


Don't you mean enabled?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.