PWM, dynamically changing period, duty cycle (directly or via DMA)
Below question relates to STM32F0 and STM32F1 series MCU's.
From the documentation (HAL), I have been unable to determine, whether or not on-the-fly changes are supported to the PWM period (TIM_TimeBaseInitTypeDef.TIM_Prescaler) and/or duty cycle (directly via CCR1 or via DMA: DMA_InitTypeDef.DMA_Memory0BaseAddr).
Other than whether or not on-the-fly changes (to a running PWM-configured timer) are supported, I am also interested in knowing when on-the-fly changes takes effect (immediate, at next timer cycle, ...)?
- When changing the address of a (circular) DMA memory buffer containing PWM duty cycle values, will it take effect immediately, or when the current (memory) cycle has been completed. I would prefer to be able to work with a double buffered DMA design, where the DMA buffer takes effect when the current cycle completes. Alternatively, I could rely on an interrupt when the cycle completes, and update the DMA buffer then.
- When changing the PWM duty cycle directly via CCR1, will this change take effect immediately, or at the end of a timer cycle.
- When changing the PWM period/frequency (via TIM_TimeBaseInitTypeDef.TIM_Prescaler) on a running PWM configured timer, will this change take effect immediately, or at the end of a cycle.
Any help and/or references to existing documentation or examples will be greatly appreciated.
/Morten