cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay stuck in Loop

GHube.1
Associate II

Hello!

First of all, im pretty new to programming STMs. I'm currently working on a project on the WL Series and stuck with the HAL_Delay function. Even something super simple like toggling my User LED won't work.

For RCC im using a TCXO 32Mhz as HSE.

while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
	  HAL_Delay(100);
  }
  /* USER CODE END 3 */
}

The LED turns on and the Code gets stuck in the Delay. I do think the interrupts are set right. 0693W000008ys3zQAA.pngAn this is my Clock Configuration:

0693W000008ys5MQAQ.png 

I'm thankful for any kind of help.

Thanks,

Gabriel

6 REPLIES 6
DavidAlfa
Senior II

Ensure Systick is enabled in System Core / SYS / Timebase source

I had a bug once where Cube IDE was missing the systick ISR code.

Open Core/Src/stm32fxxx_it.c and ensure this line is present:

void SysTick_Handler(void)
{
  /* USER CODE BEGIN SysTick_IRQn 0 */
 
  /* USER CODE END SysTick_IRQn 0 */
  HAL_IncTick();                        // <----- THIS LINE
  /* USER CODE BEGIN SysTick_IRQn 1 */
  /* USER CODE END SysTick_IRQn 1 */
}

If it's not there, just write it. I suggest making a new project and check if the issue persists, it might be a bug.

Are you using the last CubeIDE version? I think I had this in v1.5.0 or so.

If doesn't happen again in the new project, your HAL config might be corrupted (Happened twice to me), consider copying the code into the new project.

Javier1
Principal

tell us what hardware are you working with.

maybe the xtal isnnt 32Mhz? try the same software but selecting the internal clock

0693W000008ysYtQAI.png

we dont need to firmware by ourselves, lets talk
GHube.1
Associate II

Thanks for the replies!

Both Solutions didn't work...

@Javier Muñoz​ I'm using an ASVTX-13-D-32.000MHz-I05-T for the clock with VDD coming from pin 30 from the uC and pin 26 as RCC_OSC_IN from the clock, but as i said it's also not working with the HSI.

@DavidAlfa​ HAL_IncTick() was present, I'm using Version 1.6.1 IDE & 6.1.2 CubeMX. I also created a new project with just the GPIO & the clock, but that didn't work either.

DavidAlfa
Senior II

Make a simple while (c<10){ c++; } and debug it step by step, ensuring that the stm32 is actually working.

If not, try internal clock.

Check reset pin, Boot pins, Vcap value.

Post the stm32 schematic or something that could give some hints.

GHube.1
Associate II

The while loop did work perfectly.

Also with the 16Mhz HSI/MSI 32Mhz no improvement. While stuck in the Delay i did a reverse step, and i think its stuck in:

 while ((HAL_GetTick() - tickstart) < wait) { } and then the HAL_GetTick(void) function >

 return uwTick;

 BOOT0 pin was unfortunately left floating.

i read somethin about the Low Power modes and that the HSI is turned off in certain sleep modes. But i don't think i chose/activated one of those.

0693W000008z8OoQAI.pngThats the main shematic. Pin 30 is +3V3 for the clock, pin 26 the input.

DavidAlfa
Senior II

Set a breakpoint in SysTick_Handler, check if at least it's getting there.

Otherwise, the systick timer is not working.