[Suggestion, Fix] Swap SystemClock_Config() & HAL_Init()
Edit:
Seems as if this wasn't a permanent fix. It still happens ... but why?
I then always have to step through the HAL_Init & sysclockcfg functions until the timer is started. Only then can I resume the program in free running mode.
--------------------
Hi,
I'm using FreeRTOS with TIM14 as clock source on an STM32F2 and I noticed that if I just click restart during a debugging session, it would fail.
After investigating a bit, it seems that the reason is that the tick interrupt register of TIM14 wasn't cleared and therefore the mcu hangs during interrupt enabling in HAL_Init().
To fix this, I swapped SystemClock_Config() and HAL_Init() at the beginning of the main function. Now it works.
Is there any downside to this practice? If not, I suggest using this procedure per default.
Any opinions?
int main(void) {
/* USER CODE BEGIN 1 */
NVIC->ICPR[1] = 0xffffffff; // clear all pending bits
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Configure the system clock */
SystemClock_Config();
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Initialize all configured peripherals */
...
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Note: Line #4 was me trying to clear those bits. Didn't work. But doesn't harm the code either.
#debug #timbase #hang #restart #freertos