2023-06-02 01:33 AM
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.
2023-06-02 05:12 AM - edited 2023-11-20 04:07 AM
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()
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
2023-06-02 07:20 AM
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
2023-06-02 10:58 AM
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
2023-06-04 11:29 PM
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.
2023-08-31 11:25 PM
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!