Skip to main content
Associate
February 20, 2025
Question

STM32L431CBT6 blocks in HAL_Delay()

  • February 20, 2025
  • 5 replies
  • 562 views

Greetings! I am using STM32 for a very first time. I made my custom PCB with 10MHz oscillator. In the Clock Configuration window I have sellected the PLL and the HCLK is set to 80MHz (max for the uC). The outputs are all 80MHz. So I made a simple blink test program:

 

 /* USER CODE BEGIN WHILE */
 while (1)
 {
	 HAL_GPIO_TogglePin(LED_1_GPIO_Port, LED_1_Pin);
	 HAL_Delay(1000);
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }

 

The problem is my code blocks in HAL_Delay(). Here to be precise:

 

while ((HAL_GetTick() - tickstart) < wait)
 {
 }

 

I checked with oscilloscope and the quarz is working! I also tried different interrupt priorities for Sys Tick Timer.

Any other suggestions?

I have no experience with these uC.

Thanks!

5 replies

mƎALLEm
Technical Moderator
February 20, 2025

Hello @stoyanoff and welcome to the community,

Could you please attach your ioc file?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
stoyanoffAuthor
Associate
February 20, 2025
mƎALLEm
Technical Moderator
February 21, 2025

Hello,

Is that possible to share the part of the crystal connected to the MCU + the part of the LED connection with the MCU.

When you set a break point at HAL_GPIO_TogglePin(LED_1_GPIO_Port, LED_1_Pin) are you able to reach it?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Karl Yamashita
Lead III
February 20, 2025

Though it may not matter with what code you have that I see, you've have the Systick priority set to 14. Usually by default, it should be 0 like all the other interrupts.

 

Are you sure you've selected the correct pin for the LED? 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
stoyanoffAuthor
Associate
February 25, 2025

Sorry for the late responce! It seems my pcb is working correctly in release mode => when I program the uC. So I suppose the problem is in the selected debuger type. I am using ST-Link as a tool and I connected every jtag related pin to the connector. I didn`t know what to expect so I prepared the pcb for everything. I have TRST, TDI, SWDIO, TCK, TDO and NRST connected to ST-link. In the .ioc I have selected JTAG(5 pins). Is that correct? What should I use for this controller?

Thanks!

mƎALLEm
Technical Moderator
February 25, 2025

Hello, 

Please refer to the AN4555 / Figure 14. Reference design STM32L4 Series / STM32L4+ Series:

mALLEm_0-1740487699761.png

And use Serial Wire mode.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
stoyanoffAuthor
Associate
February 26, 2025

Hi! I fixed it! It seems this uC demands ROM boot mode selected. I selected RAM in the beginning which is common for TI uC. I though I have to switch  to ROM when I am ready, but here this is not the case...