//prescaler formula for period: //T = (1/APB_TIM_CLK in Hz) * (PRESCALER_Value + 1) * (PERIOD_Value (ARR register) + 1) /* Assymetric PWM mode: * CH1 & CH2 are switched to center alligned mode, when chosen more than 2 channels in Assymetric mode, the * rest will be in normal PWM mode. * TIMx->CCR1 controls length of CH1 pulse after center and length of CH2 pulse before center. * TIMx->CCR2 controls length of CH1 pulse before center and length of CH2 pulse after center. * TIMx->CCR3,4 controls length of CH3,4 pulse after center */ /* PWM dynamic duty cycle: * TIMx->CCMRxOutput ->-> OCxPE = 1 // setup of shaddow register * TIMx->CCRx = x // set pulse length * shaddow register is important for stability of program, because the new value will be written, when new * cycle is begun. */ //enable period elapsed callback TIM3->DIER |= 1 << 0; //callbacks void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ if(htim -> Instance == TIM3){ } } void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim){ if(htim -> Instance == TIM3){ } }