cancel
Showing results for 
Search instead for 
Did you mean: 

Systick not running while debugging stm32L552CEU6

jvan .2
Associate II

Im using a customboard and when it's able to upload and debug, it seems to get stuck at the HAL_Delay fucntion where get_systick(); always seems to return 0. problem with this is that i cannot find a way to solve this, and my SWD, on the chip does not seem to work rather prompt as it keeps returning Failed to initialize DAP.

5 REPLIES 5
Aime
ST Employee

Hello @jorrit van dartel​ ,

The HAL_GetTick function provides in millisecond the tick value uwTick which is a global variable used as application time base.

The tick value is incremented each 1ms in the function HAL_IncTick(void) which is called in the interrupt handler SysTick_Handler()


_legacyfs_online_stmicro_images_0693W00000dJutVQAS.png 

If the HAL_GetTick function returns 0 that should probably means that the tick value is not updated each 1ms as expected.

To check that you should add a breakpoint in the SysTick_Handler function and see if the program stops.

Best regards

Aime

Hey Aime,

Thanks for your reaction i really appreciate it, I did as you instructed and it does not enter the SysTick_Handler, which would indicate why it does not count the uwTick.

Is there a way to Fix this?

Thanks again for your quick reaction and help!

Best wishes,

Jvan

Hi @jorrit van dartel​ ,

Thank for your test. If you did not enter in the SysTick_Handler that means that you had an error on the Tick initialization.

The Tick is initialized on the first function in your main by the function HAL_Init().

The HAL_Init() function is called at the beginning of program after reset and before the clock configuration. This function configures the systick based on your default clock (after reset). Once done, time base tick starts incrementing: the tick variable counter is incremented each 1ms in the SysTick_Handler() interrupt handler.

Please check that you are using this function at the beginning of your program and if yes, check where it is failing.

Best regards,

Aime

Hey Aime,

The HAL_init(); function is used in the main void, this is also the first line in the main function.

I've put breakpoints on the erros of the clock, but it initializes correctly, but when debugging the uwTick does not count, while when not debugging and just powering the board, the code will run.

Adrian Chmiel
Associate

I had this problem several times, problem mostly time is with BOOT0 pin.

Probably in your design it is connected to something and forces a change of the interrupt vertor table address.

Please check SCB_VTOR registry, should point to flash memory (not System memory of SRAM).

You can dissable checking BOOT0 pin by unchecking Option Bytes in STM32CubeProgrammer
Option Bytes -> User Configuration -> unCheck "nSWBOOT0"

Good luck!