diff --git a/MyDrivers/Timer.c b/MyDrivers/Timer.c index 9cf2b62..eda5cae 100644 --- a/MyDrivers/Timer.c +++ b/MyDrivers/Timer.c @@ -178,13 +178,14 @@ int getArrFromFreq(float freq_khz) void PWMo_conf(TIM_TypeDef * timer, int channel, float freq_khz, float dutyCycle) { - Timer_conf(timer, getArrFromFreq(freq_khz), 0); + const int arr = getArrFromFreq(freq_khz); + Timer_conf(timer, arr, 0); LL_TIM_OC_InitTypeDef init_struct; LL_TIM_OC_StructInit(&init_struct); init_struct.OCMode = LL_TIM_OCMODE_PWM1; init_struct.OCState = LL_TIM_OCSTATE_ENABLE; - init_struct.CompareValue= dutyCycle * getArrFromFreq(freq_khz); + init_struct.CompareValue= dutyCycle * arr; LL_TIM_OC_Init(timer, channel, &init_struct); }