How to use the default SysTick configuration with a 1 ms timebase to toggle LEDs.
A “HAL_Delay” function is implemented based on the SysTick end-of-count event. LED4 toggles with a timing defined by the HAL_Delay function.
Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds) based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.
The application need to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation.
System, Cortex, Time base, Systick, HCLK
This example runs on STM32C031C6Tx devices.
This example has been tested with NUCLEO-C031C6 board and can be easily tailored to any other supported device and development board.
In order to make the program work, you must do the following :