|
@@ -178,13 +178,14 @@ int getArrFromFreq(float freq_khz)
|
178
|
178
|
|
179
|
179
|
void PWMo_conf(TIM_TypeDef * timer, int channel, float freq_khz, float dutyCycle)
|
180
|
180
|
{
|
181
|
|
- Timer_conf(timer, getArrFromFreq(freq_khz), 0);
|
|
181
|
+ const int arr = getArrFromFreq(freq_khz);
|
|
182
|
+ Timer_conf(timer, arr, 0);
|
182
|
183
|
LL_TIM_OC_InitTypeDef init_struct;
|
183
|
184
|
LL_TIM_OC_StructInit(&init_struct);
|
184
|
185
|
|
185
|
186
|
init_struct.OCMode = LL_TIM_OCMODE_PWM1;
|
186
|
187
|
init_struct.OCState = LL_TIM_OCSTATE_ENABLE;
|
187
|
|
- init_struct.CompareValue= dutyCycle * getArrFromFreq(freq_khz);
|
|
188
|
+ init_struct.CompareValue= dutyCycle * arr;
|
188
|
189
|
|
189
|
190
|
LL_TIM_OC_Init(timer, channel, &init_struct);
|
190
|
191
|
}
|