cancel
Showing results for 
Search instead for 
Did you mean: 

Hal delay stuck in infinite loop Systick

Nacluk
Associate

Hello,

I am a newbie and I have started trying to learn how to program the MCU STM32F746ZG. I have created a simple code following a learning book that uses the STM32CubeMX software. The code is a simple "Hello World" that causes LED2 to flash every 500ms. The inserted code is very simple and is the following:

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */

   HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);

   HAL_Delay(500);

 }

 /* USER CODE END 3 */

}

I have only added these two lines, the rest of the code has been generated by STM32CubeMX. When it is exported automatically to MDK-Keil v5, I make the program build and 0 errors and 0 warnings appear, apparently everything is ok. When through ST-Link I flash the MCU everything is ok too. But I notice that nothing happens ...

Looking through the debug option of MDK-Keil and although I do not understand much how it works debug making step by step I observed that it gets stuck in the Systick function, creating an infinite loop.

As I have seen by Google it seems that the code exported by STM32CubeMX causes the call to Systick interrupt to be executed from within another interruption and that due to priority systick problems it can not preempt other interrupts that have the same priority as it.

I tried to change priorities through STM32CubeMX, then I put a screenshot where it is observed as in theory Systick has higher priority than the rest but still nothing works.

0690X000006CDVMQA4.jpg

I have seen more than 100 responses to this problem where we talk about Systick priority problems with respect to other interruptions and how Systick works as a system clock if it does not have priority over the rest of the program remains stopped.

The majority of solutions usually go through edit parts of the code of some functions or change the priority manually in the code in parts that I can not even locate the large number of files that are generated between the Drivers, HAL, etc ...

I would like to correct this problem from STM32CubeMX and that the code will be exported correctly since if every error that arises must be navigated among the hundreds of files to modify the code, it seems crazy to me. I do not understand how CubeMX does not give error when exporting code if then it is going to have an incorrect operation and besides that we are talking about the simplest program that can be done, I do not even want to think that it can happen with much more complicated programs.

I would appreciate any help or suggestion on how to properly configure from CubeMX all the options so that after the initialization of the drivers, HAL, peripherals. etc ... whether it is correct or that some documentation is indicated where I explain how to configure this MCU correctly since in the manuals there is nothing clear about the thousands of configuration options that exist and what each one serves.

Thanks in advance.

1 REPLY 1

This is among many reasons that most of the programmers here aren't using CubeMX, but I wish you luck.

Use tools that allow you to find-in-files, and go to definition, or use a file manager that allows easy searching.

Code in HAL_Init() typically brings up the SysTick interrupt.

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