2017-06-12 02:17 AM
Hi everyone,
In my project, I need to generate a PWM with some parameters which need to be changed during runtime.
Here are the parameters :
- Duty cycle
- Period
- Voltage level (I think this one is not possible... maybe there is an alternative way you may know?)
First of all, I generate the PWM without troubles.
I am able to change the duty cycle on runtime using __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) macro
Now, it is possible to change the period while runtime using this kind of macro? I can't find it.
Thank you very much,
Marc
#pwm #timerSolved! Go to Solution.
2017-06-12 02:23 AM
/**
* @brief Sets the TIM Autoreload Register value on runtime without calling * another time any Init function. * @param __HANDLE__: TIM handle. * @param __AUTORELOAD__: specifies the Counter register new value. * @retval None */#define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \ do{ \ (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \ (__HANDLE__)->Init.Period = (__AUTORELOAD__); \ } while(0U)2017-06-12 02:23 AM
/**
* @brief Sets the TIM Autoreload Register value on runtime without calling * another time any Init function. * @param __HANDLE__: TIM handle. * @param __AUTORELOAD__: specifies the Counter register new value. * @retval None */#define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \ do{ \ (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \ (__HANDLE__)->Init.Period = (__AUTORELOAD__); \ } while(0U)2017-06-12 05:19 AM
Right...
I missed that... So this implies to enable 'AutoReloadPreload' register.
Anyway, thank you very much.
Marc