OK, so it appears that with projects generated through STM32CubeMX the place where to insert custom SysTick code is not within the HAL, but in one of the auto-generated “User” files, stm32f1xx_it.c. This file contains the definition of active IRQ handlers.
Here’s what the SysTick handler looks like once I modified it:
/** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ static uint32_t led_timer; /* USER CODE END SysTick_IRQn 0 */ HAL_IncTick(); HAL_SYSTICK_IRQHandler(); /* USER CODE BEGIN SysTick_IRQn 1 */ if (++led_timer >= 500) { led_timer = 0; /* Toggle LED state */ HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); } /* USER CODE END SysTick_IRQn 1 */ }
Sadly, once again, the above code does not seem to have any effect for the board I am using despite most of the code and initialization is auto-generated by STM32CubeMX. The USB setup, however, works fine. Activating the USB CDC class implementation is proving to be far easier than flipping a LED with STM32CubeMX 😀