store arr in constant
This commit is contained in:
parent
b73da08273
commit
99c0fef486
1 changed files with 3 additions and 2 deletions
|
@ -178,13 +178,14 @@ int getArrFromFreq(float freq_khz)
|
||||||
|
|
||||||
void PWMo_conf(TIM_TypeDef * timer, int channel, float freq_khz, float dutyCycle)
|
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_InitTypeDef init_struct;
|
||||||
LL_TIM_OC_StructInit(&init_struct);
|
LL_TIM_OC_StructInit(&init_struct);
|
||||||
|
|
||||||
init_struct.OCMode = LL_TIM_OCMODE_PWM1;
|
init_struct.OCMode = LL_TIM_OCMODE_PWM1;
|
||||||
init_struct.OCState = LL_TIM_OCSTATE_ENABLE;
|
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);
|
LL_TIM_OC_Init(timer, channel, &init_struct);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue