Тим 8 настраивает прерывание обновления
__HAL_RCC_TIM8_CLK_ENABLE();
TIM8 -> PSC = 999;
TIM8 -> ARR = SystemCoreClock / ((TIM8 -> PSC + 1) * freq) - 1;
TIM8 -> EGR |= TIM_EGR_UG;
if(TIM8 -> SR & TIM_SR_UIF) TIM8 -> SR = ~(TIM_SR_UIF);
TIM8 -> DIER |= TIM_DIER_UIE;
TIM8 -> CR1 = TIM_CR1_CEN;
NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn);